Page 2 of 5 FirstFirst 1234 ... LastLast
Results 26 to 50 of 106

Thread: programming challenge...

  1. #26
    newprouser
    Guest

    Default

    Quote Originally Posted by farce View Post
    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
    I found the sequence easily. just testing is taking time. i lost touch with programming , gotta practice more.

    i'm coding in c++ only anyways.

    nandini, don't stop with this please

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

    Default

    Quote Originally Posted by newprouser View Post
    I found the sequence easily. just testing is taking time. i lost touch with programming , gotta practice more.

    i'm coding in c++ only anyways.

    nandini, don't stop with this please
    sure!!
    would love to know what your logic is. We can definitely learn out of this. Well you finish with the coding first. I did it in Java.

    I'll surely post problem that tests our analytical thinking and expects the same from you guys as well.

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

    Default

    Doing was writing a poem earlier.

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

    Default

    take a string = "abcdefgh";

    reverse this without using any temp variables ;-)

    -F

  5. #30
    Pri_dm
    Guest

    Default

    give me 30 -60 mins

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

    Default

    Quote Originally Posted by farce View Post
    take a string = "abcdefgh";

    reverse this without using any temp variables ;-)

    -F
    just to be sure...

    don't we have to use any kind of temp variable?

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

    Default

    Quote Originally Posted by Pri_dm View Post
    give me 30 -60 mins
    Just post the output of the run, not the source code till
    everone has a chance to attempt it.

    thanks
    -F

    Quote Originally Posted by nandini View Post
    just to be sure...

    don't we have to use any kind of temp variable?
    actually I am not sure, I remember this being asked in an interview
    (with Cisco I think) and I did it at that time.

    Let's start trying with NO temp variables and then if that is
    impossible then we can use one.

    as usual post the results first and then the code after everyone completes.

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

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

    Default

    Did you do it in c/c++, using pointers?
    A simple yes/no will do? lol

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

    Default

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

    I was spoon fed this problem.
    Last edited by Luke Skywalker; 08-06-09 at 01:26 AM. Reason: Automerged Doublepost

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

    Default

    Quote Originally Posted by nandini View Post
    Did you do it in c/c++, using pointers?
    A simple yes/no will do? lol
    no,

    actually let me amend my condition, I think you can use variables
    for loops etc. like for (i = ..., max) etc.
    Just not a temp variable to store letters from that string.

    -F

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

    Default

    But can't recall the answer.

    trying with unicode give 45 min more.
    Last edited by Luke Skywalker; 08-06-09 at 01:32 AM. Reason: Automerged Doublepost

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

    Default reverse

    I am really really impressed with myself ;-)

    I rememebered 3 lines of code I did in an interview 10 years back!

    > !cc
    cc rrr.c
    > a.out
    before = abcdefgh
    after = hgfedcba
    >

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

    Default

    Don't give us complexion, Farce.

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

    Default

    Quote Originally Posted by nandini View Post
    Don't give us complexion, Farce.


    Nandini, if it means anything I think you are very much like me
    technically and attitude-wise. Trust me, you are going to remember
    this challenge 10 years from now ;-)

    -F

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

    Default

    Quote Originally Posted by farce View Post


    Nandini, if it means anything I think you are very much like me
    technically and attitude-wise. Trust me, you are going to remember
    this challenge 10 years from now ;-)

    -F
    Alrighto!!!

    I'll give it a try tomorrow. I am so tired that I can't concentrate.

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

    Default

    I think I need to sleep.
    My program had change & giving me this:
    p p p p
    p p p p
    p p p p
    p p p p

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

    Default

    Quote Originally Posted by nandini View Post
    Alrighto!!!

    I'll give it a try tomorrow. I am so tired that I can't concentrate.
    can you dilute?

    Quote Originally Posted by Luke View Post
    I think I need to sleep.
    My program had change & giving me this:
    p p p p
    p p p p
    p p p p
    p p p p
    you have P'd a lot ;-)

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

  18. #43
    Pri_dm
    Guest

    Default

    i = -1;
    n = 0;
    j = 0;
    k = 0;
    l = 0;
    while (n <17)
    {
    if (i < 3)
    {
    i++;
    k = 0;
    }
    else
    {
    l++;
    k = l;
    }
    for (j = 0; j<= i-l; j++)
    {
    char2DArray[i-j][k]=charArray[n];
    n++;
    k++;
    }
    }

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

    Default

    more complexion coming up.
    version 2.0 with more features and flexibility ;-)

    > a.out 0




    > a.out 1
    a



    > a.out 2
    ac
    bd


    > a.out 3
    acf
    beh
    dgi

    > a.out 4
    acfj
    beim
    dhlo
    gknp
    >

    Quote Originally Posted by Pri_dm View Post
    i = -1;
    n = 0;
    j = 0;
    k = 0;
    l = 0;
    while (n <17)
    {
    if (i < 3)
    {
    i++;
    k = 0;
    }
    else
    {
    l++;
    k = l;
    }
    for (j = 0; j<= i-l; j++)
    {
    char2DArray[i-j][k]=charArray[n];
    n++;
    k++;
    }
    }

    does this work? plese post output. (please don't post source until later)

    thanks
    -f
    Last edited by Punch Farce; 08-06-09 at 01:55 AM. Reason: Automerged Doublepost

  20. #45
    newprouser
    Guest

    Default

    are you guys discussing a different program, i jus got the answer for the first one ...

    should i post it now ??

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

    Default

    Quote Originally Posted by newprouser View Post
    are you guys discussing a different program, i jus got the answer for the first one ...

    should i post it now ??
    it is difficult to tell from pri's code ;-) but it is the first one.

    yes please, just the results, let's give Luke some time till we
    post the code.

    -F

  22. #47
    Pri_dm
    Guest

    Default

    Quote Originally Posted by farce View Post



    does this work? plese post output. (please don't post source until later)

    thanks
    -f
    yes it worked on dry run

    i = -1;
    n = 0;
    j = 0;
    k = 0;
    l = 0;

    while (n <17)
    {
    if (i < 3)
    i++;
    else
    l++;

    k = 0;
    for (j = 0; j<= i-l; j++)
    {
    char2DArray[i-j][k]=charArray[n];
    n++;
    k++;
    }
    }

    Try this farce ;-)
    Last edited by Pri_dm; 08-06-09 at 02:01 AM. Reason: Automerged Doublepost

  23. #48
    newprouser
    Guest

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

    Default

    class Math
    {
    public static void main(String[] args)
    {

    char[] charArray={'a','b','c','d','e','f','g','h','i','j' ,'k','l','m','n','o','p'};
    char[][] char2DArray=new char[4][4];
    char[][] a=new char[4][4];


    for(int x=0; x<charArray.length; x++){
    for(int d=0; d<char2DArray.length; d++){
    for(int b=0; b<char2DArray[d].length; b++){


    char2DArray[b][d] = (char)charArray[x];


    }}}
    for(int i = 0; i <= 3; i++) {
    System.out.print("");
    for(int j = 0; j <= 3; j++) {
    System.out.print(" " + char2DArray[i][j]);
    }
    System.out.println("");
    }
    System.out.println();
    }
    }

    What the hell had happened that this is not copying?
    @Farce can I pm you my poetry again?
    History is on the move,my friends.Those who cannot keep up will be left behind, to watch from distance.And those who stand in its way will not watch at all.http://windows7sins.org/
    People are going to tell stories about me none of which change who I really am.

  25. #50
    Pri_dm
    Guest

    Default

    Quote Originally Posted by Luke View Post
    @Farce can I pm you my poetry again?
    even i wanna read ur poetry

Page 2 of 5 FirstFirst 1234 ... 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
  •