WhiZTiM's Posts
Nairaland Forum › WhiZTiM's Profile › WhiZTiM's Posts
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 (of 18 pages)
@op. Thanks for the post... I remember something like this way back in Junior School... But there was something I am not sure I understood from your question . . |
Another... much shorter SLoC... http://ideone.com/HKdiNS 0.01second on my PC... when I piped input to stdin It works on my Machine... I am on a Mobile now... can't really make it run on IDEone... this is my 3rd attempt to make it work.... #annoyed.. bad phone, MTN frustrating me and my Money... PYTHON 2.5+ < 3.0
#PythonSquad |
Be more specific at your problems @OP! ... Here are 2 optimized solutions . . ... The close to fastest... C++ http://ideone.com/T2RerE took 0 seconds to run..
|
spikes C: Mogbe ooooo#hehe... You are looking for trouble ohh. |
spikes C: Mogbe ooooo. . . Yes I know... That is why i wrote. WhiZTiM: The solution I would have |
here is my solution! ...in Python 2.7
Python 3 will be
I am on an old mobile phone now... Cant IDEOne it yet. The solution I would have presented in C++, that follows the rules; has already been presented...! Thats why, I decided to make my solution shortest... Ohkay, I agree not a solution but an answer. And I used the language best suited for 'my goal' AND this exact problem... #PythonSquad. BTW, C++ rules. ... (#looksForTrouble) |
spikes C: He's already learning arabic. Watch out for his next post, he'll be writing from right to left*hahahahaha! #Oga spikes C don crack my ribs oh. Oboi, that time never come... Its probably when I am faced with a problem in Java that I would learn Arabic writing and present my solution in Arabic.. . .#hehe #i dey throw you salute! |
Judinho59:e be like sey some una conspire sey mek my phone spoil and mek MTN dey jonze me. Haba, spikes C na Oga oh... Bros, e be like sey u wan see stunts from me. Abeg, I am human. How you doing?? |
spikes C: Errrrmmm....i was saying java is cool.hahahaha. *falls off the tree. |
Haba!! Ask For Clarification! Challenge Me! And Query Me where appropriate... some of you really lack BASIC psychology skills. . . . Did I ever tell anybody I make my living solely off programming? . . . Did I ever say I would be into programming all my life? . . . What do you know about me outside Nairaland? So, attacking me for my subjective statement is outrightly pointless and TOTAL STUPIDITY... Just as started by a 'block headed', 'crackbrained', and 'shallow minded fellow'... I don't even know the gender of that person... Still, I rather learn Arabic writing than a programming language called Java. ![]() C'mon guys, where's the Nigerian spirit! |
paddy4destiny: C++ pointers are easy and fun toone love sir...! . . . me still dey talk sey, i would rather learn Arabic writing than a programming language called Java ![]() C++ pointers gives you so much power and flexibility at a certain cost... And its exceptional! Also gives the comfort ride of C... Actually, pointers are pretty simple, thanks to the compiler for precomputing the memory sizes of datatypes and objects for pointer arithmetic. . . . I wrote a little bit advanced tutorial on that a month ago.... paddy4destiny: y laughing na robotics engineeroboi, because I talk say I dey robotics engineering discipline no mean say I don collect my degree for robotics engineering oh... make I finish and join IEEE-RAS first... Anyway, I was laughing at spike C's reaction not your post.... |
spikes C: That's all we needHaha... ![]() |
Judinho59: @Spikes, i digg it now. Well, Java does more tho.you are the man! I salute you and your last 2 paragraphs!... . IMVHO . . This is more civilized. . . |
spikes C: These things are just pencils in our hands, the creatorshahaha.... You are on point! *I Salute you... |
@Javanian. False and very stupid claims... Fucckk me, your misunderstanding, aggression, blahh blah blah.... ~/~Damn! That pot you just smoked must be hot! ~~~I DID RATHER TEACH AN ASS(DONKEY) HOW TO READ AND WRITE THAN to TRADE WORDS WITH YOU MA'AM. @LordZouga, I don't think sweet features of a programming language can convince someone who has made certain programming language a god. Its like trying to convince Steve Ballmer to sponsor Linux or Linus Torvalds to join Microsoft. you see, its pointless. If I were to have a service to deliver, if applicable, I did have someone wrap and roll out my API's with preference to Java and php... Thats were I get more audience and more revenues And I still say, I rather learn Arabic writing than a language called Java... In Nachos.. .It's so idiotic to debate great languages when you aren't contributing to any language's design or implementation... As someone in the Mechanical and Robotics Engineering discipline... I say ALL LANGUAGES are tools, we have choices of work tools and its usually influenced by skillset, understanding, constraints, environment, workpeice, e.t.c... |
I respect ALL programming languages BUT ....I probably, did and rather learn Visual Basic or Arabic writing than learn the programming language called Java. @OP, in my 'subjective' opinion, Your delima should be C++ or C#. Forget platform targets. The primary language feature of C# is Java's future! Java is over 20yrs and has Billions of Dollars from many godfathers driving it! Oracle, Google, etc.... Thats why she's popular. . . .C# is just a little over 10yrs and has only Microsoft as a major godfather. But she's gaining ground with so much momentum. C++ on the other hand is an artillery building language... Such as Microsoft Windows, Mozilla Firefox, Thunderbird, Adobe CS suites, Google Chrome, Internet Explorer Microsoft Office, File servers, Graphics intensive Game Engines, Javascript Engines, National Security Software, Music production suites, Raytracing software, massive and computationally intensive simulation systems... a Python interpreter, You can even build a JVM in C++ the list is endless! ....Java can never compete these in absolute and ANY good faith. But, I THINK Java is so popular and HIGLY PRODUCTIVE for small, localized and/or limited software... I dont have the resources to do a real test.... But C# VM runs FASTER than Java's Dalvik on Android... According to xamarin.com |
I would stop derailing from the goal of your thread. . . And BTW, I have been a subscriber to code simplicity, it actually reduces maintenance burden and upgrades by the next maintainer. . . . . .and thank you for the problem. . awaiting the next problem. Cheers. |
@authurowen.... I think you should read more books to increase your comprehension skills. Lemme clear out a few things... 1. I said its sometimes a plus to write bloated codes when you are have NO concrete goal in mind... 2. Your citation with the mathematics expression shows your poor understanding of my intent... If you are damn good in maths, you could be solving a COMPLEX problem, you could express a subproblem of that problem as parametric equations etc... just to get the results you need and continue with more subproblems till you are done! But assuming it was only that subproblem that existed and you have nothing else doing, you could represent it as ODE's or some more complex model and plot graphs to investigate behavior at certain values.... Ofcause... The knowledge is just for keeps. . FOR THE RECORD: as a result of writing crazy overkills in free time, I have implemented a few algorithms that I never knew it formally existed... This started few years back, when I implemented a shortest part algorithm in a bloated solution to a code challenge.... only to later realize that it was 95% Edgar Dijkstra's algorithim! And any fair solution to that problem did not even require a graph algorithm! . . . 3. I would usually go for optimal solution in real life or any software routine... 4. Yes. I am Software tester with experience limited to GUI Applications (I use Python to automate mouse and keyboards), and C++ programs using a few arsenels... e.g Valgrind tools is my fave for blackbox testing. 6. Yes. I have participated in some programming contests, most notably, I am an ex-regionals contestant of the Worlds most renowned programming contest, ACM-ICPC... I am yet to sign up for codeforces etc, cause I know I wouldnt rise up the ranks quickly even in years. I have lots of responsibilites than programming all day or weekend. 7. If you are talking of solving problems in exact. my C++ solution beats yours in ALL endeavors. 8. Your problem is not an Engineering problem. in this context, PLEASE consider Droping the phrase "Software Engineer" or "engineering", BECAUSE your problem and solution is an insult of the first order to Engineering! ...or qualify it with "trainee", "prospective" etc. 9. Recursion builds up stack! Compilers happen to be clever than you that's why the stack size of recursive fuctions MAY be smaller compared to what it was supposed to be...! Peace.... I think we'll make good friends bro. |
hmmn... I can see someone missing a loved one. haha... nice imgs here is another.... (a little bit technical) http://pastebin.com/SemMk98v
|
Both are costly to learn... but the both pay off very well after years... You would hardly be able to show off your computer networking skills without relevant certifications... but that's not the same for programming. ~~I hope that helps a little |
This is a model of typical Nigerian courts in Java... err... It might not be the same today or tomorrow.. ![]() http://pastebin.com/e9pDBgW3
|
Welcome!! : - ) Here is an attempt, using code snippets, to make you laugh and get a glimpse of good, bad, realities, experience, etc... INFO Please post VERY easily UNDERSTOOD code snippets; such that if you posted a Java snippet and I am not a Java programmer, I would still get your point Pseudo-codes and flowcharts would also be great!! --->Posting on an ADDITIONAL link to an uploaded code of yours to a syntax highlighting site such as http://www.pastebin.com is a +1!! ---> Post codes that: ----> depicts current situation of a government agency(please also post good side of them if you know!!) ----> models a government agency, firm, or government in the world... ----> models a business or industry in the world... ----> models a celebrity, footballer, or prominent persons ----> models your experience with a lady or ladies, guy or guys.. ----> and anything that is worth posting!!! EXAMPLE: Nigerian Police Force... Nigerian Army, Nigerian Courts, Nigerian Embassy, a nigerian leader, politician, banks, footballer Microsoft, Dangote, Techno, NNPC, NSCDC, etc... ANYTHING Popular I will try to post snippets in various languages once a week for the next few weeks! keep yours rolling!!! n put a smile on our faces! ***The next post depicts type of posts*** ~Thanks. |
Here is the link ...http://pastebin.com/GAK00hF8 C#4.0 or later ........ Notice the class Program.. where the Main() function resides... look into the Main... that is how you should build up things in OOP;;; Again... this uses standard input.. (stdin) for input... @everyone: Please Criticize my code also... especially the C# PROFESSIONALS... who know any specifics of C# that I am not harnessing
|
Here is a third Solution from me.... Very bloated and fun to grasp..... Not about professionalism, but writing and drafting out toy algorithms with respect to tomorrow(no matter how stupid) pays off.... err(Don't make it too stupid though))) ...lol. I had several choices of algorthim, some, as short as my 7lines C++ algorithm version... and a recursive 6line version... BUT having 3 solutions should hopefully pass something to someone out there... I have other problems I am solving... again its for my to figure out somestuff... This solution is presented in C#.... partially 'generalistic'... Again, I make no use of optimally localized algorithm... just some very very basic stuff on grid travellers... NB: "SUBJECTIVELY" Rough benchmark for my C# code... ---The algorithm will be rated on the scale of 1 to 10.. 10 is best: Comprehension: 4 Generalization(Generic): 8 Need to Modify for other purpose: 7 Speed: 5 Memory on small input: 7 memory on large input: 7 Defense to Offense ratio: 2 NB: "SUBJECTIVELY" Rough benchmark for my C++ code... ---The algorithm will be rated on the scale of 1 to 10.. 10 is best: Comprehension: 7 Generalization(Generic): 2 Need to Modify for other purpose: 4 Speed: 10 Memory on small input: 10 memory on large input: 10 Defense to Offense ratio: 6 |
authurowen: Find below, my Implementation to the print spiral Question written in JAVA (There is very little difference btween C# and Java so C# Developers will be able to relate to it). Pls Criticize to the very lowest details as much as you please.Its TOTALLY not my pleasure to criticize your code... I hate critics and I hate to criticize... I am going to criticize you from an Engineering POV.. on the fact that you used the Phrase in your original Post. N.B: Be Genuine in your solutions, Real S.E(s) are.That phrase annoyed me so much. . . Like I said, I don't call myself a Software Engineer... I rather consider myself a Software Engineering hobbyist... ANYWAY... my small review NB: Your code is ACCEPTABLE for this exact problem in a very localized manner Also NOTE: I am Not a Java Programmer 1 I thought I was a Sappy Programmer when it comes to OOP skills and patterns until I saw what you called OOP.... I am No Java Programmer but IMHO, Your code is NOT close to being truly OOP::: You used Objects... why not have the algorithm generic for a Matrix of objects... in a generalist perspective... having all this in One object is a flawed design! Advice:: SOMETIMES, write bloated/insane codes to learn something against tomorrow... but write tight, solid, highly efficient(and probably localized) codes for production; "This code is acceptable for tight conditions like time constraints, etc" Localized implementations are always usually fastest and efficient for any problem. Broadened implementations are costly, but if and only if done well, You'll never regret doing it 2 If I ask you of these, you'll need way too much modification:: *The Inputed Array are NOT strings, but objects with features on a grid... Print them out in spiral form *the ARRAY is NOT a Square Matrix.. but print it in a deterministic manner as defined by some rules. *Print the array in ---- reverse manner starting from the center ---- Anticlockwise manner; ---- Spiral manner skipping some things... I need a callback for each element you are on... and this callback determines whether you should print the next item or not... ADVICE (2): stop hardcoding your test-run inputs... except for real testing. NB: "SUBJECTIVELY" Rough benchmark... ---The algorithm will be rated on the scale of 1 to 10.. 10 is best: Comprehension: 9 Generalization(Generic): 2 Need to Modify for other purpose: 1 Speed: 7 Memory on small input: 7 memory on large input: 1 Defense to Offense ratio: 5 That's good GOOD THINGS: Your algorithm is pretty descent and really easy to comprehend... good one, I loved it... ---the use of printing functions was a good and future-proof idea... ---Recursion is pretty good here... NB: When dealing with Matrix data that might be large... prefer iterative algorithms over recursive algorithms. ...Stop stacking up memory ---You have good approach to keeping things simple ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
kambo: Anoda passve poster in d programmg room.already seconded, thus, I am Third in line! |
danmc: i removed it like u said and now it works well. just to quote linus torvalds: "talk is cheap. show me the code", pls implement what u just said. i'd love to see it.like seriously bro??!! You are trying to put me to a show using Torvald's qoute... ...not cool. Nope. I would NOT implement it.... Nonetheless, the version I did, has 4 for loops to transverse in 4 directions. My thought to the recursive version is to have a function with several control args, transverse in only 2 directions or one preferential direction... While subsequent calls recursively controls the rest of the direction... C'mon, not everything will be given to you... think!! Haba Oga danmc At The Top!... Though... As for me... I have a knack for Robotics and Control Systems... |
@danmc. I have removed the last k++;... So try that code again... The algorithm can be implemented recursively to further beat down the SLoC by a meagre factor... @authurowen... I don't really believe in writing programs alone and calling myself a software engineer. . . . I inherently mean, I wouldnt call myself a Software Engineer. But rather a Software Engineering hobbyist.... |
danmc: tanx boss for the proggie but it still isn't perfect yet. try inputting a 3x3 matrix e.g. "1 2 3", "4 5 6" and "7 8 9". the output misses the last item in the spiral i.e. "5"! pls fix it. . .lol!... Thanks man. You are following very well sir!.... Err, my bros... If you cared to check out the logical part, you would have noticed that there was an overshoot with 'k'... THE FIX IS SIMPLE: REMOVE THE LAST "k++;" that is at the very end of the line in the last for loop... |
Here is a closely coupled working program that solves authurowens problem. Its only 30lines;... I could explain the code and make the it more readable on anybody's request... so ask if you wanna understand ....NB: I made slight modification to the initially rough snippet I wrote from my mobile phone... #EDIT... k value overshoot...FIXED
USage: all inputs are via stdin so that input values can be entered manually or by piping a file into the program.... **Input must be guaranteed to be a square matrix! **my code automatically determines the size of the grid from the first line. - - - My algorithm here is pretty simple. - - Also, try to understand my Python code, you may learn a few lazy-man's tricks... |
danmc: man, u can't just copy and paste some portion of ur code and tell us to feed it with blah blah blah. it compiled fine but couldn't run it. crash!!! i beg check ur algo well and pls show us a working proggie.Hmmn...(I wrote that snippet from my mobile) Ohhkkkay pal... I'll post a working program... |
authurowen: Brother, the solution is not as complicated as you have made it out to be. There is no need for the Mathematical / logical Gibberish (for lack of better words) you've just written.No bro... its NOT about software engineering... My python solution is not an Optimal solution in terms of speed... but I made it expose simple grid transversing to anyone that cares to understand it!! ....and I thought its so that we could all learn something? Nonetheless, HERE is my OPTIMAL CODE in C++: Its currently the FASTEST implementation I reasoned... ---this code is what I presume you may call 'software engineering'?.
I would really love to see yours in shorter lines... so that I can learn. I wouldn't bother explaining this snippet since my Python code was discarded.... BUT it works, if anyone wants, I could upload a working program.... cheers.... |
;


... (#looksForTrouble)
