1. Список говнокодов пользователя FAKYOUINTIRNEAT

    Всего: 1

  2. Куча / Говнокод #11568

    +128

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    rotate n xs = b ++ a
        where n'     = n `mod` (length xs)
          (a, b) = splitAt ((length xs) - n') xs
    
    rotateAmount xs = _ra 0 ((length xs) - 1) (listArray (0, ((length xs) - 1)) xs)
        where _ra s e ys = if (e - s) == 1 
                           then (if ((ys ! s) &lt (ys ! e)) then s else e)  -- base case
                           else let h  = ys ! s                  -- first item
                                    l  = ys ! e                  -- last item
                                    mi = s + ((e - s) `div` 2)   -- middle index
                                    m  = ys ! mi                 -- middle item
                                in if (h &lt l)
                                   then s                        -- return start index
                                   else if (h &gt m)
                                        then _ra s  mi ys
                                        else _ra mi e  ys

    A “rotated array” is an array of integers in ascending order, after which for every element i, it has been moved to element (i + n) mod sizeOfList. Write a function that takes a rotated array and, in less-than-linear time, returns n (the amount of rotation). http://techguyinmidtown.com/2008/07/05/my-answers-to-the-microsoft-interview-questions

    FAKYOUINTIRNEAT, 10 Августа 2012

    Комментарии (31)