Challenge me in PHP

Discussion in 'PHP' started by caciocode, Aug 12, 2010.

  1. #1
    Can someone solve this? I would like to challenge this PHP enthusiastic here.

    Write a script that will display the Christmas date of every 3201 years starting from today, 12/08/2010 and the weeks and moths passed until the year 60000? Can you solve that?

    Can you also give me a good challenge, something that's almost impossible.
     
    caciocode, Aug 12, 2010 IP
  2. kmap

    kmap Well-Known Member

    Messages:
    2,215
    Likes Received:
    29
    Best Answers:
    2
    Trophy Points:
    135
    #2
    i want you to write a program in php to delete all special char in a string inputted in a box and output on next page (after form submission) a string free from special char.It should not put much load on server means use regular expressions

    Regards

    Alex
     
    kmap, Aug 12, 2010 IP
  3. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #3
    Detect a human face in a given image.
     
    nico_swd, Aug 12, 2010 IP
  4. lukeg32

    lukeg32 Peon

    Messages:
    645
    Likes Received:
    19
    Best Answers:
    1
    Trophy Points:
    0
    #4
    Its not that hard if you think about it and can be done recursicely, once you avoid the usual pitfalls....

    calculate "gods number" for solving any rubiks cube starting position in php ......
     
    lukeg32, Aug 12, 2010 IP
  5. finx

    finx Greenhorn

    Messages:
    18
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    15
    #5
    A.I.

    /thread
     
    finx, Aug 12, 2010 IP
  6. caciocode

    caciocode Peon

    Messages:
    65
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #6
    I didn't quite understand that question maybe because I don't know what rubiks cube are... but sounds like a very hard question.
    Is this possible in PHP? Could someone do it if he/she had the time. I don't usually work with Image manipulation in PHP.
    I think this is possible with ereg_replace() is it not?
     
    caciocode, Aug 12, 2010 IP
  7. Rainulf

    Rainulf Active Member

    Messages:
    373
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    85
    #7
    That's not really a PHP question but programming in general. lol I'm not sure if I did it correctly, I couldn't understand your question clearly, so here:
    
    <?php
    
    $date = getdate( );
    $weeks = calcWeek($date['yday'], $date['year']);
    $months = calcMonth($date['yday'], $date['month']);
    
    echo "Today is: " . $date['year'] . ", " . $date['month'] . ", " . $date['mday'] . "<br /><br />";
    
    for($year = 2010; $year <= 60000; $year++) {
       echo "Dec 25 $year, Weeks until Christmas: $weeks<br />";
       echo "Dec 25 $year, Months until Christmas: $months<br />";
       $weeks = calcWeek((leapYear($year) ? 1 : 0), $year, $weeks);
       $months = calcMonth((leapYear($year) ? 1 : 0), $year, $months);
    }
    
    function leapYear($year) {
       if(($year % 4 == 0) && ($year % 100 != 0) || ($year % 400 == 0))
          return TRUE;
       else return FALSE;
    }
    
    function calcWeek($day, $year, $weeks=NULL) {
       if(isset($weeks)) $christmas = round(((leapYear($year) ? 360 : 359) - $day) / 7) + $weeks;
       else $christmas = round(((leapYear($year) ? 360 : 359) - $day) / 7);
       
       return $christmas;
    }
    
    function calcMonth($day, $year, $months=NULL) {
       if(isset($months)) $christmas = round(((leapYear($year) ? 360 : 359) - $day) / 31) + $months;
       else $christmas = round(((leapYear($year) ? 360 : 359) - $day) / 31);
       
       return $christmas;
    }
    
    ?>
    
    PHP:
    Calculating leap year is kinda pointless if I think about it now.. lol


    I could've used this, but there's that millennium bug thing in unix binaries:
    
    <?php
    
    for($year = 2010; $year <= 60000; $year++) {
       $date = date('Y-m-d', strtotime("25 December $year"));
       echo $date . "<br />";
    }
    
    ?>
    
    PHP:
    I heard that it's 20. ;)

    You shouldn't use ereg_*, they are deprecated. Use preg_* instead.

    Somewhat, but not accurate. Check for colour-shadings - brownish light at the center, darker at the edges. And if it's circular, then return true. Something like that.
     
    Last edited: Aug 12, 2010
    Rainulf, Aug 12, 2010 IP
  8. joebert

    joebert Well-Known Member

    Messages:
    2,150
    Likes Received:
    88
    Best Answers:
    0
    Trophy Points:
    145
    #8
    Solve every possible starting position of a Rubiks Cube in 19 moves or less.
     
    joebert, Aug 12, 2010 IP
  9. RadioBounce

    RadioBounce Banned

    Messages:
    4,171
    Likes Received:
    16
    Best Answers:
    1
    Trophy Points:
    0
    #9
    Doing that is not only going to put your PHP skills to the test but it's gonna push ability to think logically to the limit to the point at which you'll be sat in front of your computer crying and screaming "Why!? Why me!????" :p
     
    RadioBounce, Aug 12, 2010 IP
  10. Narrator

    Narrator Active Member

    Messages:
    392
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    80
    #10
    Write a script to read recaptcha or crack md5
     
    Narrator, Aug 12, 2010 IP
  11. AntelopeSalad

    AntelopeSalad Peon

    Messages:
    85
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #11
    Here's a pretty easy and popular problem:
    If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000.

    P.S., don't cheat with Google and explain your thought process during the function(s) required to do this.
     
    AntelopeSalad, Aug 12, 2010 IP
  12. RadioBounce

    RadioBounce Banned

    Messages:
    4,171
    Likes Received:
    16
    Best Answers:
    1
    Trophy Points:
    0
    #12
    I bet you'd love that.
     
    RadioBounce, Aug 12, 2010 IP
  13. danx10

    danx10 Peon

    Messages:
    1,179
    Likes Received:
    44
    Best Answers:
    2
    Trophy Points:
    0
    #13
    Thats possible.

    Can be done with OpenCV.

    A good start to read recaptcha would be OCR, also you use can bruteforce and/or use rainbow tables as an attempt to 'crack' an md5 hash but not the algorithm.

    These are just my suggestions how I would start although...I don't intend on doing so :p
     
    danx10, Aug 12, 2010 IP
  14. Narrator

    Narrator Active Member

    Messages:
    392
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    80
    #14
    Haha, actually I'd hate that since I use captchas and md5 on all my sites.
     
    Narrator, Aug 12, 2010 IP
  15. danx10

    danx10 Peon

    Messages:
    1,179
    Likes Received:
    44
    Best Answers:
    2
    Trophy Points:
    0
    #15
    Do i sense sarcasm?
     
    danx10, Aug 12, 2010 IP
  16. RadioBounce

    RadioBounce Banned

    Messages:
    4,171
    Likes Received:
    16
    Best Answers:
    1
    Trophy Points:
    0
    #16
    Yeah, that's a whole load of sarcasm right there :)
     
    RadioBounce, Aug 13, 2010 IP