Page 1 of 5 123 ... LastLast
Results 1 to 25 of 106

Thread: programming challenge...

  1. #1
    Silver Member
    Join Date
    Jun 2009
    Liked
    0 times
    Posts
    481

    Default programming challenge...

    Here is something which will surely test your programming skills.

    You have one character array:-
    char[] charArray={'a','b','c','d','e','f','g','h','i','j' ,'k','l','m','n','o','p'};

    and an emtpy 2 dimensional char array:-
    char[][] char2DArray=new char[4][4];

    Now the challenge is that you've to arrange char2DArray like this:

    a c f j
    b e i m
    d h l o
    g k n p


    anybody up for game?

  2. #2
    kirankumargb
    Guest

    Default

    I am in for it but have time only at week end

  3. #3
    Jedi knight Luke Skywalker's Avatar
    Join Date
    Jul 2009
    Age
    23
    Liked
    0 times
    Posts
    2,175

    Default

    Simple use unicode of letter.

  4. #4
    Silver Member
    Join Date
    Jun 2009
    Liked
    0 times
    Posts
    481

    Default

    Quote Originally Posted by kirankumargb View Post
    I am in for it but have time only at week end
    sure!!!

    I had got that problem yesterday. I got some leisure time today and managed to code for it successfully (don't know whether it's efficient ).

    Solve it whenever you get time.

  5. #5
    kirankumargb
    Guest

    Default

    sure, thanks for the time

  6. #6
    newprouser
    Guest

    Default

    i guess there is a matrix solution for this

  7. #7
    Silver Member
    Join Date
    Jun 2009
    Liked
    0 times
    Posts
    481

    Default

    Quote Originally Posted by Luke View Post
    Simple use unicode of letter.
    Look buddy I've not asked for any help, so no need to give any tips. We all know you're a genius. So can you please restrain yourself from enlightening us, atleast in this thread?

  8. #8
    Platinum Member
    Join Date
    Sep 2008
    Liked
    1 times
    Posts
    3,171

    Default

    I'll try it too. should be able to remember how I did it 10 or 20 years back ;-)

    -F

  9. #9
    kirankumargb
    Guest

    Default

    Quote Originally Posted by newprouser View Post
    i guess there is a matrix solution for this
    good idea

  10. #10
    newprouser
    Guest

    Default

    Quote Originally Posted by farce View Post
    I'll try it too. should be able to remember how I did it 10 or 20 years back ;-)

    -F
    you are a genius, u sure know it !!

    Quote Originally Posted by kirankumargb View Post
    good idea
    maybe i spoke a lil too early .... anyways i'll try, not good with math

  11. #11
    Jedi knight Luke Skywalker's Avatar
    Join Date
    Jul 2009
    Age
    23
    Liked
    0 times
    Posts
    2,175

    Default

    Quote Originally Posted by nandini View Post
    Look buddy I've not asked for any help, so no need to give any tips. We all know you're a genius. So can you please restrain yourself from enlightening us, atleast in this thread?
    I am not a genius.
    I just gave a tip.
    I think this thread is great & we can post new challenges.
    @Farce I did this 3 years ago.

  12. #12
    Silver Member
    Join Date
    Jun 2009
    Liked
    0 times
    Posts
    481

    Default

    Quote Originally Posted by farce View Post
    I'll try it too. should be able to remember how I did it 10 or 20 years back ;-)

    -F
    sure Farce!!! just give it a try.

    Quote Originally Posted by newprouser View Post
    maybe i spoke a lil too early .... anyways i'll try, not good with math
    you don't need to be good in mathematics in order to solve it.
    It'll be good for you NPU.

  13. #13
    Jedi knight Luke Skywalker's Avatar
    Join Date
    Jul 2009
    Age
    23
    Liked
    0 times
    Posts
    2,175

    Default

    Quote Originally Posted by newprouser View Post
    for Farce you are a genius, u sure know it !!
    The one & the only here.

  14. #14
    Platinum Member
    Join Date
    Sep 2008
    Liked
    1 times
    Posts
    3,171

    Default

    Quote Originally Posted by newprouser View Post
    you are a genius, u sure know it !!
    Quote Originally Posted by Luke View Post
    The one & the only here.
    enna vachi kaamedy, keemedy pannaliye (in vadivelu voice )

    (are you making comedy out of me)

    -F

  15. #15
    Jedi knight Luke Skywalker's Avatar
    Join Date
    Jul 2009
    Age
    23
    Liked
    0 times
    Posts
    2,175

    Default

    No.

  16. #16
    Jedi knight Luke Skywalker's Avatar
    Join Date
    Jul 2009
    Age
    23
    Liked
    0 times
    Posts
    2,175

    Default

    No. You are master of all trades & jack of none.

  17. #17
    Platinum Member
    Join Date
    Sep 2008
    Liked
    1 times
    Posts
    3,171

    Default

    Quote Originally Posted by nandini View Post
    sure Farce!!! just give it a try.
    Here's a sort of 'cheating' solution, but very efficient ;-)

    > cc ddd.c
    > a.out
    acfj
    beim
    dhlo
    gknp
    >

    I'll try a real solution soon.

    -F

  18. #18
    Silver Member
    Join Date
    Jun 2009
    Liked
    0 times
    Posts
    481

    Default

    Quote Originally Posted by farce View Post
    Here's a sort of 'cheating' solution, but very efficient ;-)

    > cc ddd.c
    > a.out
    acfj
    beim
    dhlo
    gknp
    >

    I'll try a real solution soon.

    -F
    I am gonna kill you.

  19. #19
    newprouser
    Guest

    Default

    Quote Originally Posted by farce View Post
    enna vachi kaamedy, keemedy pannaliye (in vadivelu voice )

    (are you making comedy out of me)

    -F
    Ungala poi yaaravadu kindal pannuvangala (moonu pondati purushan )

    Quote Originally Posted by farce View Post
    Here's a sort of 'cheating' solution, but very efficient ;-)

    > cc ddd.c
    > a.out
    acfj
    beim
    dhlo
    gknp
    >

    I'll try a real solution soon.

    -F
    pl pl don't post so soon, i wanna try it

    Quote Originally Posted by nandini View Post
    I am gonna kill you.
    :lol:

    voldemort had 7-8 copies of himself, no one knows how many farce has :-P

  20. #20
    Jedi knight Luke Skywalker's Avatar
    Join Date
    Jul 2009
    Age
    23
    Liked
    0 times
    Posts
    2,175

    Default

    He had 7 as seven is magical number. So had Farce.
    Now avoid off topic & post answer only.

  21. #21
    Platinum Member
    Join Date
    Sep 2008
    Liked
    1 times
    Posts
    3,171

    Default

    OK, I have done a quick and dirty solution. I won't post the source code
    till others have finished.

    > !cc
    cc ddd.c
    > a.out
    source = 0, row = 0, col = 0, nr = 0, nc = 0
    source = 1, row = 1, col = 0, nr = 1, nc = 0
    source = 2, row = 0, col = 1, nr = 1, nc = 0
    source = 3, row = 2, col = 0, nr = 2, nc = 0
    source = 4, row = 1, col = 1, nr = 2, nc = 0
    source = 5, row = 0, col = 2, nr = 2, nc = 0
    source = 6, row = 3, col = 0, nr = 3, nc = 0
    source = 7, row = 2, col = 1, nr = 3, nc = 0
    source = 8, row = 1, col = 2, nr = 3, nc = 0
    source = 9, row = 0, col = 3, nr = 3, nc = 0
    source = 10, row = 3, col = 1, nr = 3, nc = 1
    source = 11, row = 2, col = 2, nr = 3, nc = 1
    source = 12, row = 1, col = 3, nr = 3, nc = 1
    source = 13, row = 3, col = 2, nr = 3, nc = 2
    source = 14, row = 2, col = 3, nr = 3, nc = 2
    source = 15, row = 3, col = 3, nr = 3, nc = 3
    acfj
    beim
    dhlo
    gknp
    >

  22. #22
    Silver Member
    Join Date
    Jun 2009
    Liked
    0 times
    Posts
    481

    Default

    Good job Farce!!!


    Did you find it challenging?

  23. #23
    newprouser
    Guest

    Default

    Quote Originally Posted by farce View Post
    OK, I have done a quick and dirty solution. I won't post the source code
    till others have finished.

    > !cc
    cc ddd.c
    > a.out
    source = 0, row = 0, col = 0, nr = 0, nc = 0
    source = 1, row = 1, col = 0, nr = 1, nc = 0
    source = 2, row = 0, col = 1, nr = 1, nc = 0
    source = 3, row = 2, col = 0, nr = 2, nc = 0
    source = 4, row = 1, col = 1, nr = 2, nc = 0
    source = 5, row = 0, col = 2, nr = 2, nc = 0
    source = 6, row = 3, col = 0, nr = 3, nc = 0
    source = 7, row = 2, col = 1, nr = 3, nc = 0
    source = 8, row = 1, col = 2, nr = 3, nc = 0
    source = 9, row = 0, col = 3, nr = 3, nc = 0
    source = 10, row = 3, col = 1, nr = 3, nc = 1
    source = 11, row = 2, col = 2, nr = 3, nc = 1
    source = 12, row = 1, col = 3, nr = 3, nc = 1
    source = 13, row = 3, col = 2, nr = 3, nc = 2
    source = 14, row = 2, col = 3, nr = 3, nc = 2
    source = 15, row = 3, col = 3, nr = 3, nc = 3
    acfj
    beim
    dhlo
    gknp
    >
    ippadi pannitingale annan

  24. #24
    Platinum Member
    Join Date
    Sep 2008
    Liked
    1 times
    Posts
    3,171

    Default

    Quote Originally Posted by nandini View Post
    Good job Farce!!!


    Did you find it challenging?
    Yes, it was challenging, since it took me a few iterations to
    get the logic right, and still I think I should improve the code
    and make it more elegant ;-) next version coming up soon.

    -F

    Quote Originally Posted by newprouser View Post
    ippadi pannitingale annan
    I didn't post the source code, so you have no idea how I did it ;-)
    I could have hardcoded the entire thing ;-)
    sorry, please continue with your coding, don't stop.

    -F
    Last edited by Punch Farce; 08-06-09 at 12:29 AM. Reason: Automerged Doublepost

  25. #25
    Silver Member
    Join Date
    Jun 2009
    Liked
    0 times
    Posts
    481

    Default

    Quote Originally Posted by farce View Post
    Yes, it was challenging, since it took me a few iterations to
    get the logic right, and still I think I should improve the code
    and make it more elegant ;-) next version coming up soon.

    -F

    hmmnnn...
    This problem was asked in the interview which I missed last week.

Page 1 of 5 123 ... LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •