The Daily WTF: Curious Perversions in Information Technology
Welcome to TDWTF Forums Sign in | Join | Help
in Search

Solve this:

Last post 03-25-2014 4:20 AM by scuffleball. 11 replies.
Page 1 of 1 (12 items)
Sort Posts: Previous Next
  • 02-05-2013 1:06 PM

    • Nagesh
    • Top 50 Contributor
    • Joined on 01-31-2011
    • Hyderabad, India
    • Posts 1,070

    Solve this:

    There is a fashion contest running in the city and n number of panelists who are judging the contest. The Number of Judges in the contest can be 0 or any odd number(1,3,5,7......) ranging from 0 to 20. These judges are sitting in a row, holding a scorecard that displays scores obtained by each contestant ranging from 0 to m. There are two anchors standing in front of the judge who is sitting in the centre of the row.

    Now, we want to calculate total score of a contestant given by judges.

    First of all, the score given by center judge will be added to the total score.
    Secondly, the two anchors starts moving from centre position and one goes towards left (i.e. toward 1st judge) and one goes towards right (i.e. towards nth judge). They step towards their direction to new position together and they tell each other the score given by the judge. Now, If the scores given by judges are same then that score gets added to total score of that contestant. But if scores are not same then nothing is added to total score.

    Similarly, anchors keep on moving to their directions and keep comparing the scores given by judges and adding score to the total score, if matches.

     

     

    Input/Output Specs

    Input Specifications :

    Scores contained by individual n number of judges. Scores will be an integer array

    Output Specifications:

    Total score of contestant is the output. Return the output from the function as integer only

     

    Examples

    We have 5 judges and each are having scores 5,6,7,3,5

    Output : 7+5=12

    Here Anchors start walking from 3rd position. So they will take score 7 in the total. Then one anchor start moving to left and other to right. Now the scores they got is 6 and 3 but they are differnt so it will not count in total. Again they start moving, this time score given by both judges is 5 and 5, so it will count in total score. So the total score is 7+5=12.

     

     

  • 02-05-2013 1:52 PM In reply to

    • locallunatic
    • Top 50 Contributor
    • Joined on 05-19-2010
    • (YourLocation==USA-KY?local:MisleadingUsername)
    • Posts 839

    Re: Solve this:

    Here is a real quick one that uses your perscribed algorithm (though you should rework the description it so it doesn't include the algorithm to use if you are using it during hiring):

     

    SillyJudging(int[ inputArr)
    {
     if(!InputVerification(inputArr))
     {
      throw new Exception("Input is bad and you should feel bad");
     }
     int mid = inputArr.length/2;
     int i, j;
     int tot;
     tot = 0;
     j= mid;
     for(i>=0;i=mid;i--)
     {
      if(inputArr[i]==inputArr[j])
      {
       tot+=inputArr[i];
      }
      j++;
     }
     return tot;
    }

    InputVerification(int[ input)
    {
     int len = input.length;
     if(len=<0 || len>=20 || len%2==0)
     {
      return false;
     }
     return true;
    }

  • 02-15-2013 1:53 PM In reply to

    Re: Solve this:

    #lang racket
    
    (define (judge lst)
    	(if (eq? (length lst) 1)
    		(car lst)
    		(+ (if (eq? (first lst) (last lst)) (first lst) 0)
    		   (judge (cdr (reverse (cdr lst)))))))
    
    Begging the question since 2007.
  • 02-15-2013 6:45 PM In reply to

    Re: Solve this:

    Also, brainfuck:

    >>,----------[++++++++++[->+>+<<
    ]>>>,----------]<<[[-<+>]<<<[<<<
    ]>>>[-<+>]<[->>>>[>>>]<-<<[<<<]<
    ]>>>>[>>>]<<<]>[-<+>>+<]<[->+<]>
    [<<[>>>]>>[<++++++[->--------<]>
    [-<+>]]->>>]<<<[<[-<<<+>>>]<<]<[
    -<+<+>>]<<[---------[+[+[+[+[+[+
    [+[+[---------<+<<]]]]]]]]]>>>]<
    [>>>]<<<[->+>----------<<]++++++
    ++[->++++++>++++++<<]>.>.

    Enter input as a string of digits followed by newline (e.g. "56735"). Online brainfuck interpreter.

    Begging the question since 2007.
  • 02-16-2013 7:41 AM In reply to

    Re: Solve this:

    I think the system of judging like that isn't very good.
    Let's using TeXnicard.
  • 02-20-2013 3:12 PM In reply to

    Re: Solve this:

    Is there actually a challenge here?


  • 02-20-2013 4:13 PM In reply to

    • locallunatic
    • Top 50 Contributor
    • Joined on 05-19-2010
    • (YourLocation==USA-KY?local:MisleadingUsername)
    • Posts 839

    Re: Solve this:

    too_many_usernames:
    Is there actually a challenge here?

    I assume it was more of a try out an interview question (or possibly a "answer this question I got asked in an interview for me").

  • 02-24-2013 4:15 AM In reply to

    • TGV
    • Top 75 Contributor
    • Joined on 10-09-2005
    • Posts 705

    Re: Solve this:

    The challenge was to come up with an interview question that was hard to understand yet easy to code? Or just to come up with a question no-one had ever seen before.

    - Should it be a sensible question?

    - I DON'T CARE! As long as no-one has seen it before, CAPISCE???

  • 02-28-2013 9:45 AM In reply to

    • Nagesh
    • Top 50 Contributor
    • Joined on 01-31-2011
    • Hyderabad, India
    • Posts 1,070

    Re: Solve this:

    locallunatic:

    too_many_usernames:
    Is there actually a challenge here?

    I assume it was more of a try out an interview question (or possibly a "answer this question I got asked in an interview for me").

     

    There is a website called techgig that hold programming contest every month. this is one of the "easy level" programming question. The contest for Jan 2013 is over. Now to wait for next contest. 

    I already posted my entry but did not win anything. I make my post after contest is over.

     

    TechGig

     

  • 03-25-2014 3:24 AM In reply to

    Re: Solve this:

    def sillyJudging(seq :Seq[Int]) = seq.zipWithIndex.map{z => z match { case (x,y) => (seq(y), seq(seq.length - y - 1)) }}.take(seq.length/2 + 1).map{z => z match { case (x,y) => if (x==y) x else 0 }}.reduce(_+_)
  • 03-25-2014 3:52 AM In reply to

    Re: Solve this:

    or better def sillyJudging(seq :Seq[Int]) = seq.take(seq.length/2 + 1).zipWithIndex.map{z => z match { case (x,y) => (seq(y), seq(seq.length - y - 1)) }}.map{z => z match { case (x,y) => if (x==y) x else 0 }}.reduce(_+_)
  • 03-25-2014 4:20 AM In reply to

    Re: Solve this:

    or def sillyJudging(seq :Seq[Int]) = seq.take(seq.length/2 + 1).zipWithIndex.map{z => z match { case (x,y) => (if(x == seq(seq.length - y - 1)) x else 0) }}.reduce(_+_)
Page 1 of 1 (12 items)
Powered by Community Server (Non-Commercial Edition), by Telligent Systems