1. Java / Говнокод #10361

    +74

    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
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    public class factorial {
        public static void main(String[] args) {
            boolean run = true;
            long count = 2142;
            long last_count=0;
            while (run) {
                if (ispand(count)) {
                    if (isprime(count)) {
                        System.out.println(count);
                        last_count=count;
                    }
    
                }
                if((count+"").length()>7){
                   System.out.println("Largest prime can be :"+last_count);
                   System.exit(1);
                }
                count++;
            }
        }
        public static boolean ispand(long num) {
            String text = num + "";
            for (int i = 1; i <= text.length(); i++) {
                if (!text.contains(i + "")) {
                    return false;
                }
            }
            return true;
        }
        public static boolean isprime(long num) {
            if (num == 1) {
                return false;
            } else {
                for (int i = 2; i <= Math.sqrt(num); i++) {
                    if (num % i == 0) {
                        return false;
                    }
                }
            }
            return true;
        }
    }

    http://projecteuler.net/problem=41
    http://projecteuler.net/thread=41&page=8


    Пациент каким-то образом растянул решение аж на две секунды.

    PS: одному Аллаху известно почему это "factorial".

    TheHamstertamer, 24 Мая 2012

    Комментарии (95)
  2. Objective C / Говнокод #10360

    −95

    1. 1
    #define LOTS_OF_ARGS "@^v@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"

    -methodSignatureForSelector: очень рад такому повороту событий.

    farcaller, 24 Мая 2012

    Комментарии (6)
  3. Objective C / Говнокод #10359

    −104

    1. 1
    2. 2
    3. 3
    4. 4
    + (NSArray *)findAll {
    	return [self findWithPredicate: [NSPredicate predicateWithFormat:@"1 = 1"]
    							 limit: 0];
    }

    Таки да, все объекты.

    farcaller, 24 Мая 2012

    Комментарии (2)
  4. C# / Говнокод #10358

    +110

    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
    PropertyAdminFormModel data = new PropertyAdminFormModel
                    { 
                        DateFinish = rep.DateFinish,
                        Name = rep.Name,
                        ReportingCircleId = rep.ReportingCircleId
                    };
    
                    if (data != null)
                    {
                        Id = reportId;
                        Name = data.Name;
                        DateFinish = data.DateFinish;
                        ReportingCircleId = data.ReportingCircleId;
                    }

    А вдруг!? =)

    DukeGonzo, 24 Мая 2012

    Комментарии (31)
  5. PHP / Говнокод #10357

    +58

    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
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    <?php if ( $poll ) : ?>
    	<h2>Опрос: <?php echo $poll->getTitle(); ?></h2>
    	
    	<?php $count = $poll->votes->count(); ?>
    	
    	<div>Всего ответивших: <?php echo $count; ?></div>
    	
    	<?php if ( $sf_user->isAuthenticated() ) : ?>
    		
    		<?php if ( !$poll->isVote( $sf_user->getGuardUser()->getId() ) ) : ?>
    			
    			<?php foreach ( $poll->answers as $answer ) : ?>
    				<div><?php echo link_to( $answer->getTitle(), 'poll_vote', array( 'poll' => $poll->getId(), 'answer' => $answer->getId() ) ); ?></div>
    			<?php endforeach; ?>
    			
    		<?php else : ?>
    			
    			<?php foreach ( $poll->answers as $answer ) : ?>
    				<div><?php echo $answer->getTitle(); ?> ($count / <?php echo $answer->getPercent( $count ); ?>%)</div>
    			<?php endforeach; ?>
    			
    		<?php endif; ?>
    		
    	<?php else : ?>
    		
    		<?php foreach ( $poll->answers as $answer ) : ?>
    			<div><?php echo $answer->getTitle(); ?></div>
    		<?php endforeach; ?>
    		
    		<div>Что бы выбрать вариант ответа, необходимо войти.</div>
    		
    	<?php endif; ?>
    	
    <?php endif; ?>

    Пал выбор, делать проверку, голосовал пользователь или нет в цикле и выводить соответствующую инфу или сделать проверку и использовать два разных цикла в разных ветках

    psycho-coder, 24 Мая 2012

    Комментарии (2)
  6. Java / Говнокод #10356

    +127

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    pFirst = new LinePoints;
    pFirst->ptPixel.x = ptOrig.x*szStart.cx/15 + ptStart.x;
    pFirst->ptPixel.y = (15-ptOrig.y)*szStart.cy/15 + ptStart.y;
    pFirst->next = NULL;
    if(pFirst != NULL)
    {
        ...

    Ну а правда, вдруг NULL?

    someone, 24 Мая 2012

    Комментарии (13)
  7. C# / Говнокод #10355

    +90

    1. 1
    public string Материал_Clean { get; set; }

    :[

    nolka4, 24 Мая 2012

    Комментарии (2)
  8. PHP / Говнокод #10354

    +139

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    a = 0;
    if (a == 0) {
    } else {
    b = a;
    }

    GggTtt, 23 Мая 2012

    Комментарии (4)
  9. JavaScript / Говнокод #10353

    +152

    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
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    $(document).ready(function(){
     var m;
     function fourSize()
     {
        var size=$(window).width();
    	if (size<'1210') { css='1000'; m=160;}
    	if ((size>='1210')&&(size<'1296')) {css='1240';m=160;}
    	if ((size>='1296')&&(size<'1370')) {css='1320';m=180;}
    	if(size>='1370') {css='1400';m=180;}
        $('#four-size').attr({	href: 'css/styles_'+css+'.css'});marginFoot();
     } 
     function marginFoot()
        {
            w=$(window).width();
            h=$(window).height();
            if (h<500)  $('.center').css('height',($(window).height()-m));
            if ((h>500 && w<1210)||(h>600 && w>1210)){
            $('.center').css('height',($(window).height()-m)); //alert($(document).height()-180);
            margin=$(window).height()-$('.center').height()-m;
            $('.foot').css('margin-top',margin);}
        }   
        fourSize();marginFoot();
        $(window).resize(function(){fourSize();})
        
    })

    У парня 1 год опыта верстки и js.

    katsgeorgeek, 23 Мая 2012

    Комментарии (3)
  10. JavaScript / Говнокод #10352

    +138

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    <script>window.google={kEI:"iBS9T5-8NY6CtQbXmN3PDQ",getEI:function(a){var b;while(a&&!(a.getAttribute&&(b=a.getAttribute("eid"))))a=a.parentNode;return b||google.kEI},https:function(){return window.location.protocol=="https:"},kEXPI:"24878,27400,30316,31215,35702,35703,38100,38135,38221,38285,38738,38786,38816,38941,39000",kCSI:{e:"24878,27400,30316,31215,35702,35703,38100,38135,38221,38285,38738,38786,38816,38941,39000",ei:"iBS9T5-8NY6CtQbXmN3PDQ"},authuser:0,
    ml:function(){},pageState:"#",kHL:"uk",time:function(){return(new Date).getTime()},log:function(a,b,c,e){var d=new Image,h=google,i=h.lc,f=h.li,j="";d.onerror=(d.onload=(d.onabort=function(){delete i[f]}));i[f]=d;if(!c&&b.search("&ei=")==-1)j="&ei="+google.getEI(e);var g=c||"/gen_204?atyp=i&ct="+a+"&cad="+b+j+"&zx="+google.time();
    var k=/^http:/i;if(k.test(g)&&google.https()){google.ml(new Error("GLMM"),false,{src:g});delete i[f];return}d.src=g;h.li=f+1},lc:[],li:0,j:{en:1,l:function(){google.fl=true},e:function(){google.fl=true},
    b:location.hash&&location.hash!="#",bv:21,cf:"osb",pm:"p",pl:[],mc:0,sc:0.5,u:"f05f80a8"},Toolbelt:{},y:{},x:function(a,b){google.y[a.id]=[a,b];return false}};(function(){var a=
    google.j;window.onpopstate=function(){a.psc=1};for(var b=0,c;c=["ad","bc","inpr","is","p","pa","ac","pc","pah","ph","sa","sifp","slp","spf","spn","xx","zc","zz"][b++];)(function(e){a[e]=function(){a.pl.push([e,arguments])}})(c)})();if(!window.chrome)window.chrome={};window.chrome.sv=2.00;window.chrome.userWantsQuery=function(a){google.x({id:"psyapi"},function(){google.nav.search({q:encodeURIComponent(a),
    sourceid:"chrome-psyapi1"})})};
    window.google.sn="webhp";window.google.timers={};window.google.startTick=function(a,b){window.google.timers[a]={t:{start:(new Date).getTime()},bfr:!(!b)}};window.google.tick=function(a,b,c){if(!window.google.timers[a])google.startTick(a);window.google.timers[a].t[b]=c||(new Date).getTime()};google.startTick("load",true);try{}catch(u){}
    </script>

    GggTtt, 23 Мая 2012

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