How to use it as a code?

** ***** ** ** ** ** ** ** ** **** ** ** ** ** *** ** ** ** ******************** ********************* 

Original solutions are welcome. The option with the most votes wins.

 function getAnswers(questionId, answer_filter, page) { return jQuery.ajax({ url: '//api.stackexchange.com/2.2/questions/' + questionId + '/answers?page=' + page + '&pagesize=100&order=desc&sort=activity&site=ru.stackoverflow&filter=' + answer_filter, method: "get", dataType: "jsonp", crossDomain: true }).then(function(data) { if (data.has_more) { return getAnswers(questionId, answer_filter, page + 1).then(function(d) { return data.items.concat(d.items); }) } return data.items; }); } function getAuthorName(e) { return e.owner.display_name } function process(items) { return items.map(function(item) { var matched = item.body.match(/<h\d+>\s*(.+?)\s*<\/h/); if (matched) { return { lang: matched[1], count: item.score, link: item.share_link, author: getAuthorName(item) }; } else { return { lang: "N/A", count: "N/A", link: item.share_link, author: getAuthorName(item) } } }); } function sort(items) { return items.sort(function(a, b) { return b.count - a.count; }) } function fillTemplate(sortedItems) { $('#leadership').append(sortedItems.map(function(item, index) { return $('<tr>').append($('<td>').html(index + 1)) .append($('<td>').html(item.author)) .append($('<td>').html(item.lang)) .append($('<td>').html(item.count)) .append($('<td>').append($('<a>').attr('href', item.link).text('Link'))); })); return sortedItems; } var QUESTION_ID = 520257, ANSWER_FILTER = "!4*SyY(4Kifo3Mz*lT", startPage = 1; getAnswers(QUESTION_ID, ANSWER_FILTER, startPage) .then(process) .then(sort) .then(fillTemplate); 
 #leadership { border-collapse: collapse; } #leadership td, #leadership th { padding: 5px; } #leadership th { text-align: center; } 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <h1>Таблица лидеров</h1> <table id="leadership"> <tr> <th></th> <th>Автор</th> <th>Язык</th> <th>Счет</th> <th></th> </tr> </table> 

  • one
    and <?php echo '***...'; can be considered use as a code ? )) And the converter "razmezdochek" in the brainfuck can be considered? And only a specific image can be used or the idea itself? - BOPOH
  • Maybe add a label [code golf]? - val
  • @BOPOH, yes, echo is possible, but it is hardly original enough to get a plus sign. Is there any idea that does not work on a particular image? - Qwertiy
  • @val, competition replaces it. Golf is still supposed to be estimated by the number of characters. - Qwertiy
  • And when awarding winners conceived? - edem

5 answers 5

C ++

http://ideone.com/JRY307

 struct outputter { outputter operator*(); }; int main(int argc, char* argv[]) { outputter o; ** ***** ** ** ** ** ** ** ** **** ** ** ** ** *** ** ** ** ******************** ********************* o; return 0; } #include <iostream> #include <string> #include <sstream> #include <iterator> using namespace std; string text = "IF you happen to have read another book about Christopher Robin, " "you may remember that he once had a swan (or the swan had Christopher " "Robin, I don't know which) and that he used to call this swan Pooh. " "That was a long time ago, and when we said good-bye, we took the name " "with us, as we didn't think the swan would want it any more. " "Well, when Edward Bear said that he would like an exciting name all to himself, " "Christopher Robin said at once, without stopping to think, that he was " "Winnie-the-Pooh."; istringstream iss{ text }; auto it = istream_iterator<string>{ iss }; outputter outputter::operator*() { cout << *it++ << " "; return *this; } 

Idea: we will declare a class with the * operator, which will return the object itself. In this way, you can call the operator * as many times as you like.

To make an object do something useful, take text from Winnie the Pooh ( string text = ... ), put it into the iss stream, and read from the stream with an iterator ( istream_iterator ) (streaming a line read reads one word at a time, , as with cin , so we actually split the text into words by spaces). Each time the operator is running * derive the next word and advance the iterator.

  • You can outline in general what is what and why it works? In C++ I know three and a half operators, but it looks impressive. - user207618
  • one
    @Other: Added to the answer. - VladD
  • one
    And why vector? istream_iterator not incremental? - Qwertiy
  • one
    @edem: Good question. I think it is at the discretion of the author. Although an idea for contests a good idea would be to announce the duration of the competition in advance. - VladD
  • one
    @edem, issued :) - Qwertiy

Clojure

 '(** ***** ** ** ** ** ** ** ** **** ** ** ** ** *** ** ** ** ******************** *********************) 

As well as this ... do not believe it:

 (** ***** ** ** ** ** ** ** ** **** ** ** ** ** *** ** ** ** ******************** *********************) 

... this is a list of characters that are used to represent identifiers in code as data (Clojure, however, Lisp, remember?). And IDs in Clojure have pretty insane freedom in naming. Yes, they may well consist of stars!

If there were no quotes at the beginning, it would try to resolve identifiers ***** , ** , ******************** , ********************* , *** and **** , could not (because they are not), and would have fallen. But you can define them:

 (let [** (fn [& args]) ; функция, принимает любое число аргументов и не делает ничего ; но это моя реализация, в ней можно что-нибудь и сделать ; ** надо быть чем-то функциеподобным, ведь он будет вызван ...] ; ...и остальные тоже нужно определить, хоть nil'ами (** ***** ** ** ** ** ** ** ** **** ** ** ** ** *** ** ** ** ******************** *********************)) 

Well, quite uninteresting case:

 (comment ** ***** ** ** ** ** ** ** ** **** ** ** ** ** *** ** ** ** ******************** *********************) 

This is nil . Well, comment is a macro collapsing to nil . Here is its implementation:

 (defmacro comment "Ignores body, yields nil" {:added "1.0"} [& body]) ; после объявления списка аргументов *ничего нет* 

This is not exactly a comment, in the usual sense, the comment form must be syntactically correct code, otherwise the form will be incorrect and the execution will fall. But this symbol is quite a valid Clojure-code! .. well, without definitions.

Macros, perhaps you can make something interesting out of it.

    Perl

    This logo can be a little scary if you put it on top of the perl-script:

    main.pl:

     use strict; use warnings; use utf8; use Ohlabishch; use re 'eval'; ************************************** *;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;* *****''=~('(*****?{**'.**('[^@._['.*** ***'**|~{+]**].-%@]**@**?+__'^******** ***'+**,)@**+{^?[_$****}]@@,>('.****** ***'^@**~**}').'})'** **);;;;;;;;;**** ***;;;;***;;;;;;;;;**;;**;;;;;;;;;**** ***;;;;;;;;;;;;;;;;;;;; **;;;;;;;;**** ***;;;;********************;;;;;;;**** ***;;;;*********************;;;;;;**** ***;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;**** *;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;** ************************************** 

    Ohlabishch.pm:

     package Ohlabishch; use strict; use warnings; use Filter::Simple sub { s/\*//g }; 1; 

    How does this mess of characters work?

    Step 1 . We connect the Ohlabishch module, the task of which is to remove all the characters from the original one.

    Without them, this code will look like:

     ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ''=~('(?{'.('[^@._['. '|~{+]].-%@]@?+__'^ '+,)@+{^?[_$}]@@,>('. '^@~}').'})' );;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;; ;;;;;;;; ;;;;;;;;;;; ;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 

    Step 2 . Add an empty operation ; which, again, do nothing. Without it, the code has the form (last ; let's leave it all the same):

     ''=~('(?{'.('[^@._['. '|~{+]].-%@]@?+__'^ '+,)@+{^?[_$}]@@,>('. '^@~}').'})' ); 

    Step 3 . Compound strings, where possible, and write everything into one line:

     '' =~ ( '(?{' . ( '[^@._[|~{+]].-%@]@?+__' ^ '+,)@+{^?[_$}]@@,>(^@~}' ) . '})' ); 

    Step 4 . Consider carefully the line:

     '[^@._[|~{+]].-%@]@?+__' ^ '+,)@+{^?[_$}]@@,>(^@~}' 

    Despite its frightening appearance, its task is quite simple, to use the xor operation for these two lines character by character. Those:

     perl -E 'say "["^"+"' p perl -E 'say "^"^","' r 

    etc. As a result, we get a line of the form: print "A ty smelchak!"

    Step 5 . At the moment, the code is converted to:

     '' =~ ( '(?{' . ( 'print "A ty smelchak!"' ) . '})' ); 

    Step 6 . We remove the extra brackets and string concatenation characters, thus obtaining the intended code:

     '' =~ ( '(?{ print "A ty smelchak!" })' ); 

    What it is? This is just a "regular expression" that applies to an empty string. The regular expression itself is the form "(?{ code })" , which allows you to execute code in the given regular expression. By default, it is disabled, and to connect it you need to add the following line to the program: use re 'eval' . That's all!

    • 2
      And what is the result? - VladD
    • one
      @VladD "A ty smelchak!" - edem

    C ++

    http://ideone.com/VpcGQz

     int main() { ** ***** ** ** ** ** ** ** ** **** ** ** ** ** *** ** ** ** ******************** ********************* main;} 

      C ++

       int main(int argc, const char * argv[]) { cout << R"( ** ***** ** ** ** ** ** ** ** **** ** ** ** ** *** ** ** ** ******************** ********************* )"; } 
      • Hmm .. string literal ... Although about R did not know. And trim the tail - he moved something. - Qwertiy