Stats: 3,186,929 members, 7,931,213 topics. Date: Sunday, 25 August 2024 at 07:13 PM |
Nairaland Forum / Science/Technology / Programming / Simple Code Challenge: C#, Java, C, C++ (19184 Views)
Please Help With This Simple Code / Programming FUN With Code Snippets!! -C++,C#, Java,php,python Or Any Language!! / Code Challenge [1]: Pseudo-code, C#, JAVA (apply Object Oriented Principles) (2) (3) (4)
(1) (2) (3) (4) (5) (Reply) (Go Down)
Re: Simple Code Challenge: C#, Java, C, C++ by blindcopy: 5:23pm On Jun 09, 2011 |
Wow, I should have seen this earlier ![]() I think @whoelse has the most awesome solution! ![]() Everybody else just dey blow grammar. See longlong variable names! See comments! Kai, people like to dey WRITE! Me, I come from the old school where when typing into your BBC computer with 8 kilobytes of RAM you dread the ever so common "Out Of Memory" error and remove all them tiresome comments! LOLOLOL! Complexity analysis? We got some eggheads here! ![]() ![]() Ah, so @Beaf gave himself the prize by suddenly adding a new condition after the fact? Bad, bad Beaf! But after seeing the prize one can understand why he would want her for himself! LOLOLOL! Me, would I have entered? Well, no ![]() But only because I don't believe in coding contests where you are judged by some arbitrary factor! If you have a contest where the code is judged by a. does it compile b. does it generate the desired output c. does it have the fewest lines of the submissions d. does it solve the problem in the shortest time And the conditions for (b) are CLEARLY stated, then I will surely enter. I dont want someone looking at my code and telling me that because I am comparing two constants I fail!!! LOLOLOLOLOL! |
Re: Simple Code Challenge: C#, Java, C, C++ by blindcopy: 5:26pm On Jun 09, 2011 |
@Beaf I never knew you were a coder. My respect for you has just gone up like 80%!! After all your endless trolling in the political sections had already eroded that respect to like 2% or something! ![]() Lets see more of you here and less of you there, eh? I have never posted there, or in the romance sections, etc cos I think they are the time wasters of Nairaland, where people go to waste the time God has given them ![]() |
Re: Simple Code Challenge: C#, Java, C, C++ by kokoye(m): 8:40pm On Jun 09, 2011 |
Jesus Christ! I am a consultant in the telecom sector but a stark illiterate on this thread oh well . .that's life |
Re: Simple Code Challenge: C#, Java, C, C++ by cameronese(m): 9:43pm On Jun 09, 2011 |
I think @whoelse has the most awesome solution! Cheesy @Blindcopy, are you a coder or you just wanna say something?? Every programmer here know that all the participants are on some point. You may as well keep quiet and watch (just advice, no offence) |
Re: Simple Code Challenge: C#, Java, C, C++ by xanadu: 10:19pm On Jun 09, 2011 |
This has got to be the most interesting and intellectually stimulating thread I have seen on Nairaland in years! |
Re: Simple Code Challenge: C#, Java, C, C++ by kidgenious(m): 8:12pm On Jun 10, 2011 |
Damn am impressed, this has really pushed up ma interest in programming to like 60%.well am thinking you guys can open a class for wannaBE programmers like me to learn.lookin @ll dose codes like wth are you guys writing.but its all cool, Thumbs up ![]() |
Re: Simple Code Challenge: C#, Java, C, C++ by Nobody: 8:33pm On Jun 10, 2011 |
Interesting Topic |
Re: Simple Code Challenge: C#, Java, C, C++ by Nobody: 1:13am On Jun 14, 2011 |
Removed |
Re: Simple Code Challenge: C#, Java, C, C++ by mrofficial(m): 9:29am On Jun 14, 2011 |
Na wa ooo, MrBible self dey run code. Na inside bible you learn am? lol. |
Re: Simple Code Challenge: C#, Java, C, C++ by Nobody: 9:40am On Jun 14, 2011 |
mr.official Na wa ooo, MrBible self dey run code. Na inside bible you learn am? lol.Thank God you showed up here, I was beginning to think that everyone interested in this thread have been caught up in the rapture that was suppose to have taken place last month ![]() ![]() ![]() The amount of coding in the Bible is more than the coding in any programming language you can think of, the problem is that very few people find the time to decode the coding in the Bible, thereby they make the mistake of allowing false preachers to decode it for them. |
Re: Simple Code Challenge: C#, Java, C, C++ by whoelse(m): 10:51am On Jun 14, 2011 |
MrBible: @MrBible Just so u know, Beaf has the winning code. ![]() ![]() I also think ur making the same mistake i initially made. Ur variable fullArray is not one array but 3. Take note. |
Re: Simple Code Challenge: C#, Java, C, C++ by Nobody: 11:10am On Jun 14, 2011 |
whoelse I also think your making the same mistake i initially made. your variable fullArray is not one array but 3. Take note.But why use 3 arrays to hold the fullArray, this is an inefficient way to write codes, when 1 can do the job. I can rewrite the code to use just 1 fullArray. If Beaf will crown me the new winner. ![]() ![]() ![]() |
Re: Simple Code Challenge: C#, Java, C, C++ by whoelse(m): 11:36am On Jun 14, 2011 |
MrBible: I feel ur pain bro if this is cos of that hawt prize ![]() MrBible: Just for a while imagine that ur fullArray is actually 3 arrays as follows. int[] fullArray1 = {0,8,1,0,0,0,8,6,7,8,9,5,2,6,3,0,7,4,1,1,0,0,7,0,0,8,6,7,8,9,5,9,1,1,3,0}; int[] fullArray2 = {1,0,0,0,8,6,7,8,9,1,3,0,0,8,5,2,6,3,0,7,4,1,1,0,0,7,0,0,8,6,7,8,9,5,9,1}; int[] fullArray3 = {1,0,5,2,6,3,0,7,4,1,1,0,0,7,0,0,8,6,7,8,9,5,0,0,8,6,7,8,9,1,3,0,0,8,9,1}; and also the search Array int[] searchArray = {1, 3, 0, 0, 8}; Looking at arrays fullArray2 and fullArray3, its easy to see that the searchArray is a contained in both of them. The trick is mainly in fullArray1 where the searchArray starts from around the end of the array and goes to the beginning. Do u get now? |
Re: Simple Code Challenge: C#, Java, C, C++ by Nobody: 11:45am On Jun 14, 2011 |
Whoelse, thanks I have gone back to check Beaf's initial post and in it he wants the patterns to be in 3 arrays. I have made some improvements to your code to meet Beaf's requirements, I will post the code soon. |
Re: Simple Code Challenge: C#, Java, C, C++ by mrofficial(m): 6:50pm On Jun 14, 2011 |
MrBible: Rapture ke, I been dey expect am before, but since our old man don tell us say him do mistake, say na October 21, me don relax my mind and continue life. Till then again. So which one you come dey decode here? Na from bible? |
Re: Simple Code Challenge: C#, Java, C, C++ by Nobody: 7:24pm On Jun 14, 2011 |
Rapture ke, I been dey expect am before, but since our old man don tell us say him do mistake, say na October 21, me don relax my mind and continue life. Till then again. So which one you come dey decode here? Na from bible? Me too I was waiting for the rapture but since the Man Of God Harold Camping got the date wrong, so I decided to take up coding as decoding the date of the rapture and coding are very similar. With very good coders on this forum I'm hoping that we'll all work together so that we can help the MOG Harold Camping to decode the next date of the rapture correctly. |
Re: Simple Code Challenge: C#, Java, C, C++ by Nobody: 1:21am On Jun 15, 2011 |
Interesting Topic |
Re: Simple Code Challenge: C#, Java, C, C++ by Fayimora(m): 3:20am On Jun 15, 2011 |
Please put your code back into the code tags ![]() |
Re: Simple Code Challenge: C#, Java, C, C++ by mrofficial(m): 10:13am On Jun 15, 2011 |
MrBible: ![]() ![]() ![]() ![]() I hope you guyz see am decode. Good luck. ![]() |
Re: Simple Code Challenge: C#, Java, C, C++ by Nobody: 10:39pm On Jun 16, 2011 |
I have actually been looking at this page and would like to make a comment or two. I don't do intense programming in any language, but do some reasonable algorithms building. Considering the problem posed, I think literally looping the array is not so possible, unless one desires an infinite loop. But it is fairly possible to provide an illusion of looping. public class SearchArray { public static void main(String[] args) { int parentArray[] = {, } int searchArray[]= {, } int x[]=new int[parentArray.length+searchArray.length-1); //provide illusion of looping for (int i=0;i<=parentArray.length-1;++i){ x[i]=parentArray[i]; } for (int i=0;i<=searchArray.length-2;++i){ x[parentArray.length+i]=parentArray[i]; } int p,q,c=0; //conduct search for (int i=0;i<=parentArray.length-1;++i){ p=0;q=i; do { if (x[q]==searchArray[p]){ ++c; } else c=0; ++p; ++q; } while(p<=searchArray.length-1); if (c==searchArray.length){ System.out.printf("%d\n",i); c=0; } } } } it's also possible to increment the parent Array by its earliest items as one goes about comparing the search Array with it. In this case, a code x(parentArray.length+i)=parentArray(i); for every case of comparing with search Array. By end of search array, parent Array would have increased by 2*parentArray.length. Coming late, Hope this makes sense though |
Re: Simple Code Challenge: C#, Java, C, C++ by drakula941: 8:05pm On Nov 08, 2011 |
This my code in java, i took d array in 1 variable, is dat fyn?? class codes{ public static void main(String arg[]){ int code[]={0,8,1,0,0,0,8,6,7,8,9,5,2,6,3,0,7,4,1,1,0,0,7,0,0,8,6,7,8,9,5,9,1,1,3,0,1,0,0,0,8,6,7,8,9,1,3,0,0,8,5,2,6,3,0,7,4,1,1,0,0,7,0,0,8,6,7,8,9,5,9,1,1,0,5,2,6,3,0,7,4,1,1,0,0,7,0,0,8,6,7,8,9,5,0,0,8,6,7,8,9,1,3,0,0,8,9,1}; for(int x=0;x<code.length;x++){ try{ if(code[x]==1&&code[x+1]==3&&code[x+2]==0&&code[x+3]==0&&code[x+4]== ![]() ![]() }catch(Exception ex){} } } } |
Re: Simple Code Challenge: C#, Java, C, C++ by candylips(m): 11:22pm On Jan 17, 2012 |
let me see if i can work on a scala solution |
Re: Simple Code Challenge: C#, Java, C, C++ by 9ja4eva: 8:46pm On Jan 20, 2012 |
Any VB guru on here.I need some clarification please, |
Re: Simple Code Challenge: C#, Java, C, C++ by Beaf: 8:32am On Jan 25, 2012 |
blindcopy: Dude, I am not into the "respect" thing. Opinions differ on various issues and must be expressed freely. Also, people are various things that are not immediately obvious. what I do with my time is entirely my business. No? |
Re: Simple Code Challenge: C#, Java, C, C++ by candylips(m): 11:01am On Jan 31, 2012 |
Beaf. but why do u waste so much time and effort in the politics section. ![]() As a coder u should be engaging urself in more intellectual stimulating exercises. That politics section is just a rabbit hole. |
Re: Simple Code Challenge: C#, Java, C, C++ by Beaf: 9:38pm On Jan 31, 2012 |
candylips: Bros, if dem send una, make una tell dem say una no see me! ![]() Lol! Is the bolded a joke? Except those stimulating exercises can't be found on NL, cos the politics section is far more entertaining than this section. Most of what you find in this section are many lazy people asking things like "how to send emails." I'd rather go to the politics section to catch fun and wind up one or two crawling, mud munching, grass gripping clods (there be plenty there [size=4pt] like Gbawe and alj haram lol!!![/size]). ![]() ![]() ![]() |
Re: Simple Code Challenge: C#, Java, C, C++ by 9ja4eva: 8:35pm On Feb 02, 2012 |
@Beaf Guy abeg u dey good in Visual Basic 2010? I need help urgently, or can u refer me to anyone abeg? |
Re: Simple Code Challenge: C#, Java, C, C++ by Beaf: 6:34pm On Feb 03, 2012 |
9ja4eva: Nah, I generally advice peeps to switch to C#. However, whats the problem? |
Re: Simple Code Challenge: C#, Java, C, C++ by candylips(m): 6:41pm On Feb 03, 2012 |
Mr Beaf u too like politics |
Re: Simple Code Challenge: C#, Java, C, C++ by GreyBeard: 8:08pm On Feb 04, 2012 |
I just came across this thread and I'm loving the coding entries. @Beaf - Since your original post said the solution should be done in a single for loop, do the Java and C# entries qualify since they are all calling a for loop from a seperate method up to 3 times. So in actual fact, the for loop gets called 3 times and not once. Just saying ![]() |
Re: Simple Code Challenge: C#, Java, C, C++ by Beaf: 10:00pm On Feb 04, 2012 |
@candylips Lol! Werin man go do? Grey Beard: Which of the examples are you pointing out? The two winning ones don't have that problem (except I'm mistaken). |
Re: Simple Code Challenge: C#, Java, C, C++ by candylips(m): 11:30pm On Feb 04, 2012 |
Beaf am still trying out a functional solution to this problem. Am new to functional programming |
Nigerian Ethical Hackers In Here ---> / Programming Challenge For Beginners N20000 / C++ Tutorial For Beginners... Part 1...
(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. 50 |