• Quine

    phillc        
    0 Likes0 Commentspython

    s='s=%r;print s%%s...';print s%s...
  • ai

    other019        
    0 Likes0 Commentsjavascript

    class GameAi{
      constructor(){
      	//initcall 
    		//minimax (currentPos,3,Number.NEGATIVE_INFINITY,Number.POSITIVE_INFINITY,true);
    	}
    	gameAssesState(position){
    		//algorytm oceniania stanug gry
    		//wyższa ocena im bliżej do celu
    		//prawdopodbne poziomy inteligencji 
    		// 8**3 = 512 liści
    		// 8**5 = 32768 liści
    		// 8**7 = 2097152 liści
    	}
    	isGameOver(position){
    
    	}
    	minimax(position,depth,alpha,beta,maximizingPlayer){
    		if (depth == 0 || isGameOver(position))
    			return gameAssesState(position);
    		if (maximizingPlayer){
    			var maxEval = Number.NEGATIVE_INFINITY;
    			var childs = getChilds(position);
    			child.forEach(
    				function(child){
    					var eval = minimax(child,depth-1,alpha,beta,false);
    					maxEval = Math.max(maxEval,eval);
    					alpha = Math.max(alpha,eval);
    					if (beta<=alpha){
    						break;
    					}
    				}
    			);
    			return maxEval;
    		}
    		else{
    			var minEval = 
    		}
    
    	}
    }
    
  • Bae

    ihowarth        
    0 Likes0 Commentsjavascript

    const Kim = {
      size: "XS",
      hotness: "∞"
    };
  • Hello World in Go

    abemassry        
    0 Likes0 Commentsgolang

    package main
    
    import "fmt"
    func main() {
      fmt.Println("Hello World")
    }
  • Hello World

    mparke        
    0 Likes0 Commentsjavascript

    <script>alert('hello world');</script>
  • One liner to print all of unicode

    abemassry        
    0 Likes0 Commentssh

    for i in `bc <<< "obase = 16 ; $(seq 0 65536)" | tr '\n' ' '`; do printf "$i:"; printf "\u$i"; printf '\n'; done | rs -e | less
  • Function Captchas

    Dorthu        
    0 Likes0 Commentspython

    >>> def captcha(challenge=None, answer=None):
    ...   def _dec(f):
    ...     @wraps(f)
    ...     def _inner(*args, **kwargs):
    ...       if not challenge in kwargs or not kwargs[challenge] == answer:
    ...         raise ValueError('captcha failed!')
    ...       del kwargs[challenge]
    ...       return f(*args, **kwargs)
    ...     return _inner
    ...   return _dec
    ...
    >>> @captcha(challenge='two_plus_three', answer=5)
    ... def foo(bar):
    ...   print("bar is {}".format(bar))
    ...
    >>> foo('test')
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "<stdin>", line 6, in _inner
    ValueError: captcha failed!
    >>> foo('test', two_plus_three=5)
    bar is test
  • Distilled Greatness

    Dorthu        
    0 Likes0 Commentsperl

    print map { tr/at/pl/r } grep { (ord) % 4 < 3 } sort split //, 'great';
  • Holy hell

    Akiiino        
    1 Likes0 Commentspython

    x = train_data[train_data[:,1].argsort()][(lambda label_count: list(itertools.chain.from_iterable(range(i, i+50) for i in [0]+label_count[:-1]))+list(itertools.chain.from_iterable(range(i+50, j) for i,j in zip([0]+label_count, label_count))))(list(itertools.accumulate(labels.count(a) for a in range(500))))]
  • Functional Ruby

    jaturken        
    0 Likes0 Commentsruby

    def push_page_urls_to_queue(url, doc)
      doc.xpath('//a/@href').
        map{ |link| link.text.strip }.
          select{ |u| belongs_to_domain?(u, url) }.
            map { |u| full_url(u, url) }.
              select{ |u| !already_crawled?(u) }.
                map { |u| queue << { url: u, priority: url_priority(u) } }
    end