答:
Pip, <s>62</s> <s>55</s> <s>54</s> 50 bytes

Takes the string as a command-line argument.

```<code>aR-`([^.?!] )?\[\?]( [^aeiou])?`{[b"aA"@!b'nX!cc]}
</code>```

Try it online!

Explanation:

```<code>a                                                   Cmdline argument
 R                                                  Replace...
  -`                           `                    The following regex (case-insensitive):
    ([^.?!] )?                                      Group 1: not end-of-sentence (nil if it doesn't match)
              \[\?]                                 [?]
                   ( [^aeiou])?                     Group 2: not vowel (nil if there is a vowel)
                                {                }  ... with this callback function (b = grp1, c = grp2):
                                 [              ]   List (concatenated when cast to string) of:
                                  b                 Group 1
                                   "aA"@!b          "a" if group 1 matched, else "A"
                                          'nX!c     "n" if group 2 didn't match, else ""
                                               c    Group 2
</code>```

Title: An A , or An An?

Body:
In English, there is the fun and simple difference between an and a: you use an when preceding a word starting with a vowel sound, and a when the word starts with a consonant sound.

For the sake of simplicity in this challenge, an precedes a word that starts with a vowel (aeiou), and a precedes a word that starts with a consonant.

Input

A string comprising only printable ASCII characters, with [?] appearing in places where you must choose to insert an or a. [?] will always appear before a word. You can assume that the sentence will be grammatically correct and formatted like normal.

Output

The input string with [?] replaced with the appropriate word (an or a). You do have to worry about capitalization!

When to Capitalize

Capitalize a word if it is preceded by no characters (is the first one in the input) or if it is preceded by one of .?! followed by a space.

Examples

```<code>Input: Hello, this is [?] world!
Output: Hello, this is a world!

Input: How about we build [?] big building. It will have [?] orange banana hanging out of [?] window.
Output: How about we build a big building. It will have an orange banana hanging out of a window.

Input: [?] giant en le sky.
Output: A giant en le sky.

Input: [?] yarn ball? [?] big one!
Output: A yarn ball? A big one!

Input: [?] hour ago I met [?] European.
Output: A hour ago I met an European.

Input: Hey sir [Richard], how 'bout [?] cat?
Output: Hey sir [Richard], how 'bout a cat?
</code>```

This is code-golf, so shortest code in bytes wins!

Body:
Pip, <s>62</s> <s>55</s> <s>54</s> 50 bytes

Takes the string as a command-line argument.

aR-`([^.?!] )?\[\?]( [^aeiou])?`{[b"aA"@!b'nX!cc]}

Try it online!

Explanation:

a                                                   Cmdline argument
 R                                                  Replace...
  -`                           `                    The following regex (case-insensitive):
    ([^.?!] )?                                      Group 1: not end-of-sentence (nil if it doesn't match)
              \[\?]                                 [?]
                   ( [^aeiou])?                     Group 2: not vowel (nil if there is a vowel)
                                {                }  ... with this callback function (b = grp1, c = grp2):
                                 [              ]   List (concatenated when cast to string) of:
                                  b                 Group 1
                                   "aA"@!b          "a" if group 1 matched, else "A"
                                          'nX!c     "n" if group 2 didn't match, else ""
                                               c    Group 2


问:
"Hello, World!"
So... uh... this is a bit embarrassing. But we don't have a plain "Hello, World!" challenge yet (despite having 35 variants tagged with hello-world, and counting). While this is not the most interesting code golf in the common languages, finding the shortest solution in certain esolangs can be a serious challenge. For instance, to my knowledge it is not known whether the shortest possible Brainfuck solution has been found yet.

Furthermore, while all of <s>Wikipedia</s> (the Wikipedia entry has been deleted but there is a copy at archive.org
), esolangs and Rosetta Code have lists of "Hello, World!" programs, none of these are interested in having the shortest for each language (there is also this GitHub repository). If we want to be a significant site in the code golf community, I think we should try and create the ultimate catalogue of shortest "Hello, World!" programs (similar to how our basic quine challenge contains some of the shortest known quines in various languages). So let's do this!

The Rules

Each submission must be a full program.

The program must take no input, and print Hello, World! to STDOUT (this exact byte stream, including capitalization and punctuation) plus an optional trailing newline, and nothing else.

The program must not write anything to STDERR.

If anyone wants to abuse this by creating a language where the empty program prints Hello, World!, then congrats, they just paved the way for a very boring answer.

Note that there must be an interpreter so the submission can be tested. It is allowed (and even encouraged) to write this interpreter yourself for a previously unimplemented language.

Submissions are scored in bytes, in an appropriate (pre-existing) encoding, usually (but not necessarily) UTF-8. Some languages, like Folders, are a bit tricky to score - if in doubt, please ask on Meta.

This is not about finding the language with the shortest "Hello, World!" program. This is about finding the shortest "Hello, World!" program in every language. Therefore, I will not mark any answer as "accepted".

If your language of choice is a trivial variant of another (potentially more popular) language which already has an answer (think BASIC or SQL dialects, Unix shells or trivial Brainfuck-derivatives like Alphuck), consider adding a note to the existing answer that the same or a very similar solution is also the shortest in the other language.

As a side note, please don't downvote boring (but valid) answers in languages where there is not much to golf - these are still useful to this question as it tries to compile a catalogue as complete as possible. However, do primarily upvote answers in languages where the authors actually had to put effort into golfing the code.

For inspiration, check the Hello World Collection.

The Catalogue

The Stack Snippet at the bottom of this post generates the catalogue from the answers a) as a list of shortest solution per language and b) as an overall leaderboard.

To make sure that your answer shows up, please start your answer with a headline, using the following Markdown template:

```<code>## Language Name, N bytes
</code>```

where N is the size of your submission. If you improve your score, you can keep old scores in the headline, by striking them through. For instance:

```<code>## Ruby, <s>104</s> <s>101</s> 96 bytes
</code>```

If there you want to include multiple numbers in your header (e.g. because your score is the sum of two files or you want to list interpreter flag penalties separately), make sure that the actual score is the last number in the header:

```<code>## Perl, 43 + 2 (-p flag) = 45 bytes
</code>```

You can also make the language name a link which will then show up in the snippet:

```<code>## [><>](https://esolangs.org/wiki/Fish), 121 bytes
</code>```

/* Configuration */

var QUESTION_ID = 55422; // Obtain this from the url
// It will be like https://XYZ.stackexchange.com/questions/QUESTION_ID/... on any question page
var ANSWER_FILTER = "!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe";
var COMMENT_FILTER = "!)Q2B_A2kjfAiU78X(md6BoYk";
var OVERRIDE_USER = 8478; // This should be the user ID of the challenge author.

/* App */

var answers = [], answers_hash, answer_ids, answer_page = 1, more_answers = true, comment_page;

function answersUrl(index) {
  return "https://api.stackexchange.com/2.2/questions/" +  QUESTION_ID + "/answers?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + ANSWER_FILTER;
}

function commentUrl(index, answers) {
  return "https://api.stackexchange.com/2.2/answers/" + answers.join(';') + "/comments?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + COMMENT_FILTER;
}

function getAnswers() {
  jQuery.ajax({
    url: answersUrl(answer_page++),
    method: "get",
    dataType: "jsonp",
    crossDomain: true,
    success: function (data) {
      answers.push.apply(answers, data.items);
      answers_hash = [];
      answer_ids = [];
      data.items.forEach(function(a) {
        a.comments = [];
        var id = +a.share_link.match(/\d+/);
        answer_ids.push(id);
        answers_hash[id] = a;
      });
      if (!data.has_more) more_answers = false;
      comment_page = 1;
      getComments();
    }
  });
}

function getComments() {
  jQuery.ajax({
    url: commentUrl(comment_page++, answer_ids),
    method: "get",
    dataType: "jsonp",
    crossDomain: true,
    success: function (data) {
      data.items.forEach(function(c) {
        if (c.owner.user_id === OVERRIDE_USER)
          answers_hash[c.post_id].comments.push(c);
      });
      if (data.has_more) getComments();
      else if (more_answers) getAnswers();
      else process();
    }
  });
}

getAnswers();

var SCORE_REG = /<h\d>\s*([^\n,<]*(?:<(?:[^\n>]*>[^\n<]*<\/[^\n>]*>)[^\n,<]*)*),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/;

var OVERRIDE_REG = /^Override\s*header:\s*/i;

function getAuthorName(a) {
  return a.owner.display_name;
}

function process() {
  var valid = [];

  answers.forEach(function(a) {
    var body = a.body;
    a.comments.forEach(function(c) {
      if(OVERRIDE_REG.test(c.body))
        body = '
' + c.body.replace(OVERRIDE_REG, '') + '
';
    });

    var match = body.match(SCORE_REG);
    if (match)
      valid.push({
        user: getAuthorName(a),
        size: +match[2],
        language: match[1],
        link: a.share_link,
      });
    else console.log(body);
  });

  valid.sort(function (a, b) {
    var aB = a.size,
        bB = b.size;
    return aB - bB
  });

  var languages = {};
  var place = 1;
  var lastSize = null;
  var lastPlace = 1;
  valid.forEach(function (a) {
    if (a.size != lastSize)
      lastPlace = place;
    lastSize = a.size;
    ++place;

    var answer = jQuery("#answer-template").html();
    answer = answer.replace("{{PLACE}}", lastPlace + ".")
                   .replace("{{NAME}}", a.user)
                   .replace("{{LANGUAGE}}", a.language)
                   .replace("{{SIZE}}", a.size)
                   .replace("{{LINK}}", a.link);
    answer = jQuery(answer);
    jQuery("#answers").append(answer);

    var lang = a.language;
    lang = jQuery(''+lang+'').text();

    languages[lang] = languages[lang] || {lang: a.language, lang_raw: lang, user: a.user, size: a.size, link: a.link};
  });

  var langs = [];
  for (var lang in languages)
    if (languages.hasOwnProperty(lang))
      langs.push(languages[lang]);

  langs.sort(function (a, b) {
    if (a.lang_raw.toLowerCase() > b.lang_raw.toLowerCase()) return 1;
    if (a.lang_raw.toLowerCase() < b.lang_raw.toLowerCase()) return -1;
    return 0;
  });

  for (var i = 0; i < langs.length; ++i)
  {
    var language = jQuery("#language-template").html();
    var lang = langs[i];
    language = language.replace("{{LANGUAGE}}", lang.lang)
                       .replace("{{NAME}}", lang.user)
                       .replace("{{SIZE}}", lang.size)
                       .replace("{{LINK}}", lang.link);
    language = jQuery(language);
    jQuery("#languages").append(language);
  }

}```
<pre class="snippet-code-css lang-css prettyprint-override"><code>body {
  text-align: left !important;
  display: block !important;
}

#answer-list {
  padding: 10px;
  width: 290px;
  float: left;
}

#language-list {
  padding: 10px;
  width: 500px;
  float: left;
}

table thead {
  font-weight: bold;
}

table td {
  padding: 5px;
}</code>```

<link rel="stylesheet" type="text/css" href="https://cdn.sstatic.net/Sites/codegolf/all.css?v=ffb5d0584c5f">

Shortest Solution by Language

Language	User	Score

Leaderboard

	Author	Language	Size

{{PLACE}}	{{NAME}}	{{LANGUAGE}}	{{SIZE}}	Link

{{LANGUAGE}}	{{NAME}}	{{SIZE}}	Link

```

答:
Dialpha bytecode, 44 bytes

Bytecode in Base64:

```<code>2voBAAEhAWQBbAFyAW8BVwEgASwBbwFsAWwBZQFIBQ8qAAAAHgseAAAAHwA=
</code>```

Assembly code:

```<code>push8 0
"Hello, World!"
:loop
dup
jiz end
putc
jump loop
:end
flush
halt
</code>```

ContentLicense: CC BY-SA 4.0

Title: "Hello, World!"

Body:
Dialpha bytecode, 44 bytes

Bytecode in Base64:

2voBAAEhAWQBbAFyAW8BVwEgASwBbwFsAWwBZQFIBQ8qAAAAHgseAAAAHwA=

Assembly code:

push8 0
"Hello, World!"
:loop
dup
jiz end
putc
jump loop
:end
flush
halt

ContentLicense: CC BY-SA 3.0


问:
An A , or An An?
In English, there is the fun and simple difference between an and a: you use an when preceding a word starting with a vowel sound, and a when the word starts with a consonant sound.

For the sake of simplicity in this challenge, an precedes a word that starts with a vowel (aeiou), and a precedes a word that starts with a consonant.

Input

A string comprising only printable ASCII characters, with [?] appearing in places where you must choose to insert an or a. [?] will always appear before a word. You can assume that the sentence will be grammatically correct and formatted like normal.

Output

The input string with [?] replaced with the appropriate word (an or a). You do have to worry about capitalization!

When to Capitalize

Capitalize a word if it is preceded by no characters (is the first one in the input) or if it is preceded by one of .?! followed by a space.

Examples

```<code>Input: Hello, this is [?] world!
Output: Hello, this is a world!

Input: How about we build [?] big building. It will have [?] orange banana hanging out of [?] window.
Output: How about we build a big building. It will have an orange banana hanging out of a window.

Input: [?] giant en le sky.
Output: A giant en le sky.

Input: [?] yarn ball? [?] big one!
Output: A yarn ball? A big one!

Input: [?] hour ago I met [?] European.
Output: A hour ago I met an European.

Input: Hey sir [Richard], how 'bout [?] cat?
Output: Hey sir [Richard], how 'bout a cat?
</code>```

This is code-golf, so shortest code in bytes wins!

答:
Perl 6, 78 bytes

{S:i:g/(^|<[.?!]>' ')?'[?] '(<[aeiou]>?)/{$0 xx?$0}{A>[?$0]}{'n'x?~$1} $1/}
```

<h2>Explanation:</h2>

<pre class="lang-perl6 prettyprint-override"><code>{
  S
    :ignorecase
    :global
  /
    ( # $0
    | ^             # beginning of line
    | <[.?!]> ' '   # or one of [.?!] followed by a space
    ) ?             # optionally ( $0 will be Nil if it doesn't match )

    '[?] '          # the thing to replace ( with trailing space )

    ( # $1
      <[aeiou]> ?   # optional vowel ( $1 will be '' if it doesn't match )
    )

  /{
    $0 xx ?$0      # list repeat $0 if $0
                   # ( so that it doesn't produce an error )
  }{
    < a A >[ ?$0 ] # 'A' if $0 exists, otherwise 'a'
  }{
    'n' x ?~$1     # 'n' if $1 isn't empty
                   # ｢~｣ turns the Match into a Str
                   # ｢?｣ turns that Str into a Bool
                   # ｢x｣ string repeat the left side by the amount of the right

  # a space and the vowel we may have borrowed
  } $1/
}
</code>```

Test:

#! /usr/bin/env perl6
use v6.c;
use Test;

my &code = {S:i:g/(^|<[.?!]>' ')?'[?] '(<[aeiou]>?)/{A>[?$0]~('n'x?~$1)} $1/}

my @tests = (
  'Hello, this is [?] world!'
  => 'Hello, this is a world!',

  'How about we build [?] big building. It will have [?] orange banana hanging out of [?] window.'
  => 'How about we build a big building. It will have an orange banana hanging out of a window.',

  '[?] giant en le sky.'
  => 'A giant en le sky.',

  '[?] yarn ball?'
  => 'A yarn ball?',

  '[?] hour ago I met [?] European.'
  => 'A hour ago I met an European.',

  "Hey sir [Richard], how 'bout [?] cat?"
  => "Hey sir [Richard], how 'bout a cat?",
);

plan +@tests;

for @tests -> $_ ( :key($input), :value($expected) ) {
  is code($input), $expected, $input.perl;
}
```

<pre class="lang-perl6 prettyprint-override"><code>1..6
ok 1 - "Hello, this is a world!"
ok 2 - "How about we build a big building. It will have an orange banana hanging out of a window."
ok 3 - "A giant en le sky."
ok 4 - "A yarn ball?"
ok 5 - "A hour ago I met an European."
ok 6 - "Hey sir [Richard], how 'bout a cat?"
</code>```

Title: An A , or An An?

Body:
Perl 6, 78 bytes

{S:i:g/(^|<[.?!]>' ')?'[?] '(<[aeiou]>?)/{$0 xx?$0}{<a A>[?$0]}{'n'x?~$1} $1/}

Explanation:

{
  S
    :ignorecase
    :global
  /
    ( # $0
    | ^             # beginning of line
    | <[.?!]> ' '   # or one of [.?!] followed by a space
    ) ?             # optionally ( $0 will be Nil if it doesn't match )

    '[?] '          # the thing to replace ( with trailing space )

    ( # $1
      <[aeiou]> ?   # optional vowel ( $1 will be '' if it doesn't match )
    )

  /{
    $0 xx ?$0      # list repeat $0 if $0
                   # ( so that it doesn't produce an error )
  }{
    < a A >[ ?$0 ] # 'A' if $0 exists, otherwise 'a'
  }{
    'n' x ?~$1     # 'n' if $1 isn't empty
                   # ｢~｣ turns the Match into a Str
                   # ｢?｣ turns that Str into a Bool
                   # ｢x｣ string repeat the left side by the amount of the right

  # a space and the vowel we may have borrowed
  } $1/
}

Test:

#! /usr/bin/env perl6
use v6.c;
use Test;

my &code = {S:i:g/(^|<[.?!]>' ')?'[?] '(<[aeiou]>?)/{<a A>[?$0]~('n'x?~$1)} $1/}

my @tests = (
  'Hello, this is [?] world!'
  => 'Hello, this is a world!',

  'How about we build [?] big building. It will have [?] orange banana hanging out of [?] window.'
  => 'How about we build a big building. It will have an orange banana hanging out of a window.',

  '[?] giant en le sky.'
  => 'A giant en le sky.',

  '[?] yarn ball?'
  => 'A yarn ball?',

  '[?] hour ago I met [?] European.'
  => 'A hour ago I met an European.',

  "Hey sir [Richard], how 'bout [?] cat?"
  => "Hey sir [Richard], how 'bout a cat?",
);

plan +@tests;

for @tests -> $_ ( :key($input), :value($expected) ) {
  is code($input), $expected, $input.perl;
}

1..6
ok 1 - "Hello, this is a world!"
ok 2 - "How about we build a big building. It will have an orange banana hanging out of a window."
ok 3 - "A giant en le sky."
ok 4 - "A yarn ball?"
ok 5 - "A hour ago I met an European."
ok 6 - "Hey sir [Richard], how 'bout a cat?"


问:
Let's get Animated!

The Challenge

GIFs are the most common image format for animation, and are used pretty heavily in today's social media. For the purpose of this challenge, I'm going to redefine what a GIF can be. This challenge will require you to take in a 3D array containing some sort of representation of a 2D 'image' and iterate through them, displaying an animation. This animation can be done anywhere, in a GIF, in your console, in a GUI, etc; the delivery doesn't matter, so long as it is animated.

The Input

A 3D array where the data inside somehow represents a 2D image.

The array may contain RGB data, true/false data or anything else you see fit.

I'm also fine with you dumbing it down to a 2D array of strings or something similar, but the animation must be a 2D animation.

The time between each frame in a format of your choosing (Seconds, Milliseconds, etc...).

People have been asking me whether or not they HAVE to include the duration length. My answer is "meh", as long as you are able to show animation. I'm more concerned that you adhere to the "Array" parameter than this one, meaning no random animations.

The Output

A seamlessly iterated sequence of output that looks like a 2D animation with the correct delay on each transition based on the value input.

The Rules

Output can be, but is not limited to:

GIF image.

GUI animation (my example).

In-console animation.

Honestly, any "animation" that you see fit, as long as it follows the below rules.

When outputting your image you must clear the console before showing the next frame, you cannot just print them sequentially.

Emulating a console "clear" is also acceptable, as long as it looks like a seamless animation (see the hint under my example for more information on what I mean).

Regardless of implementation, your animation should loop forever, or until stopped.

The "looping" can be as simple as while(true){} or infinite recursion, you may assume the user wants to view this masterpiece until they hit "ctrl+c".

You must be able to handle any size 2D 'images', if your language is limited by buffer sizes, this is acceptable and you may state this in your explanation.

Standard loopholes are disallowed.

Example I/O

Input (3D Array, Delay)

```<code>f([
  [[1,0,0],
   [0,0,0],
   [0,0,0]],
  [[0,0,0],
   [0,1,0],
   [0,0,0]],
  [[0,0,0],
   [0,0,0],
   [0,0,1]],
], 1)
</code>```

Output (Example, 2020 Bytes - Java)

```<code>import javax.swing.JFrame;
import javax.swing.JTextArea;

/**
 * Simple GIF class to animate a 3D integer array in a swing text area.
 * (Clearing the console in java isn't something you really do, so I chose
 * java on purpose to make it an extremely ungolf-able answer that someone
 * wouldn't bother to steal).
 */
public class Gif implements Runnable {
    /**
     * The output area.
     */
    private final JTextArea area;

    /**
     * The list of images.
     */
    private final int[][][] images;

    /**
     * The delay between image transitions.
     */
    private final long transitionDelay;

    /**
     * Main method, instantiates a GIF object and runs it.
     * @param args Does absolutely nothing.
     */
    public static void main(String[] args) {
        final int[][][] images = {{{1,0,0},{0,0,0},{0,0,0}},{{0,0,0},{0,1,0},{0,0,0}},{{0,0,0},{0,0,0},{0,0,1}}};
        final long transitionDelay = 1000L;
        new Thread(new Gif(images, transitionDelay)).start();
    }

    /**
     * Constructor for a GIF, takes in a 3D array of images and a transition
     * delay to wait between transitioning the images.
     * @param images The list of images.
     * @param delay The delay between each image.
     */
    public Gif(int[][][] images, long transitionDelay) {
        this.images = images;
        this.transitionDelay = transitionDelay;
        this.area = new JTextArea();
        final JFrame frame = new JFrame("It's a GIF!");
        frame.setSize(10,100);
        frame.add(area);
        frame.setVisible(true);
    }

    /**
     * When run, it will alter the area to imitate an animated GIF.
     */
    @Override
    public void run() {
        while (true) {
            for (int i = 0; i < images.length; i++) {
                final StringBuffer frame = new StringBuffer();
                for (int j = 0; j < images[i].length; j++) {
                    for (int k = 0; k < images[i][j].length; k++) {
                        frame.append("" + images[i][j][k]);
                    }
                    frame.append("\n");
                }
                this.area.setText(frame.toString());
                try{Thread.sleep(transitionDelay);}catch(Exception e){}
                this.area.setText("");
            }
        }
    }
}
</code>```

This results in a swing GUI popping up, animating the array:

HINT HINT: Use a language where console clearing is possible, or specify why what you are doing will end up with a result that looks like an animation in the language you chose. I think some languages have default buffer sizes on their consoles, you may use this to your advantage, but I expect an explanation or example. Just because I output my animation as a string, you don't have to; I could've just as easily used 0 for black and 1 for white and made a real GIF.

Judging

This is code-golf, lowest byte count wins (inputs excluded).

I'll +1 anyone who uses a language in a cool or unexpected way as well.

答:
sed 141 134 90

-51 thanks to seshoumara

```<code>/^$/!{H;d}
:;/^$/g;s,^\n,,;s,$, ,;s,^,\d27[2J,p
:p;P;s,[^\n]*\n,,;/^ \n/!bp;N;s,[ \n]*,,;b
</code>```

Input: First takes each frame separated by a line with a single space then display the next frame after each blank line is received (looks like a flipbook). Minimum 3 frames.

By default on my system (Windows 7) when I open cygwin it have 24 lines vertically. Between frames, there are always at least that many blank lines printed. This effectively clears the screen.

Over 1/3 of the bytes come from clearing the console. I'm sure there's a better way.

Title: Let's get Animated!

Body:
sed 141 134 90

-51 thanks to seshoumara

/^$/!{H;d}
:;/^$/g;s,^\n,,;s,$, ,;s,^,\d27[2J,p
:p;P;s,[^\n]*\n,,;/^ \n/!bp;N;s,[ \n]*,,;b

Input: First takes each frame separated by a line with a single space then display the next frame after each blank line is received (looks like a flipbook). Minimum 3 frames.

By default on my system (Windows 7) when I open cygwin it have 24 lines vertically. Between frames, there are always at least that many blank lines printed. This effectively clears the screen.

Over 1/3 of the bytes come from clearing the console. I'm sure there's a better way.


问:
Comparing powers.
Compare two numbers N1 = abc, N2 = def by constructing a function f(a,b,c,d,e,f) that:

returns 1 if N1 > N2

returns -1 if N1 < N2

Note: You are not required to return any value for any other relation between N1 and N2. e.g. when they are equal or when their relation is undefined (complex numbers).

other constrains:

all numbers are integers

a,b,c,d,e,f may be positive or negative but not zero.

|a|,|d| < 1000

|b|,|c|,|e|,|f| < 1010

running time less than few seconds

Examples:

```<code>f(100,100,100,50,100,100) = 1
f(-100,100,100,50,100,100) = 1
f(-100,99,100,50,100,100) = -1
f(100,-100,-100, -1, 3, 100) = 1
f(535, 10^9, 10^8, 443, 10^9, 10^9) = -1
</code>```

This is code golf. Shortest code wins.

答:
Python 2.6 (this doesn't actually work)

```<code>import cmath
g=cmath.log
f=lambda a,b,c,d,e,f:-1+2*((c*g(b)+g(g(a))-f*g(e)-g(g(d))).real>0)
</code>```

today i learnt python has a complex log function. so, blindly double log both sides and look at the real component. works for 4 out of the 5 tests. not sure what's happening with the fourth one.

```<code>print f(100,100,100,50,100,100) == 1
print f(-100,100,100,50,100,100) == 1
print f(-100,99,100,50,100,100) == -1
print f(100,-100,-100, -1, 3, 100) == 1 # failure, sadness.
print f(535, 10^9, 10^8, 443, 10^9, 10^9) == -1
</code>```

ContentLicense: CC BY-SA 2.5

Title: Comparing powers.

Body:
Python 2.6 (this doesn't actually work)

import cmath
g=cmath.log
f=lambda a,b,c,d,e,f:-1+2*((c*g(b)+g(g(a))-f*g(e)-g(g(d))).real>0)

today i learnt python has a complex log function. so, blindly double log both sides and look at the real component. works for 4 out of the 5 tests. not sure what's happening with the fourth one.

print f(100,100,100,50,100,100) == 1
print f(-100,100,100,50,100,100) == 1
print f(-100,99,100,50,100,100) == -1
print f(100,-100,-100, -1, 3, 100) == 1 # failure, sadness.
print f(535, 10^9, 10^8, 443, 10^9, 10^9) == -1


问:
Simulate the Wireworld cellular automaton
Wireworld is a cellular automaton that was designed to be resemble electrons flowing through wires. Its simple mechanics allow the construction of digital circuits.  It has even permitted the construction of an entire computer.

Your mission is to create the shortest Wireworld implementation in your language of choice.

Each cell in the grid has one out of four states.  The four states are "blank," "copper," "electron head," or "electron tail."

A blank cell will always remain a blank cell

An electron head will always become an electron tail

An electron tail will always become copper

A copper cell will become an electron head iff exactly one or two out of its eight neighbors are electron heads, otherwise it will remain copper

This competition will have a similar style to the Shortest Game of Life competition, but with a few changes.

The grid must be at least 40 by 40 cells

The edges of the grid must NOT wrap around (not a torus). Treat cells outside of the field as being constantly "blank."

It must be possible for the users to enter their own starting configuration.

Staring at blank screens is not fun.  The program must visually display the simulation as it is running.

This is code golf,  fewest bytes wins.

答:
Python, 234 218 chars

```<code>import time
I=input
C=I()
H=I()
T=I()
R=range(40)
while 1:
 for y in R:print''.join(' CHT'[(C+H+2*T).count(x+y*1j)]for x in R)
 H,T=[c for c in C if 0<sum(1 for h in H if abs(c-h)<2)<3and c not in H+T],H;time.sleep(.1)
</code>```

You input the board as three list of complex numbers representing the coordinates of the cells of copper (which must include the heads and tails lists), heads, and tails.  Here's an example:

```<code>[3+2j+x for x in range(8)] + [3+4j+x for x in range(8)] + [11+3j+x for x in range(6)] + [2+3j]
[3+2j]
[2+3j]
</code>```

Note that we eval the input, so you can use arbitrarily complex expressions for lists of complex numbers.

Body:
Python, 234 218 chars

import time
I=input
C=I()
H=I()
T=I()
R=range(40)
while 1:
 for y in R:print''.join(' CHT'[(C+H+2*T).count(x+y*1j)]for x in R)
 H,T=[c for c in C if 0<sum(1 for h in H if abs(c-h)<2)<3and c not in H+T],H;time.sleep(.1)

You input the board as three list of complex numbers representing the coordinates of the cells of copper (which must include the heads and tails lists), heads, and tails.  Here's an example:

[3+2j+x for x in range(8)] + [3+4j+x for x in range(8)] + [11+3j+x for x in range(6)] + [2+3j]
[3+2j]
[2+3j]

Note that we eval the input, so you can use arbitrarily complex expressions for lists of complex numbers.


问:
Output the largest number with the fewest digits
Given a nonempty list of positive decimal integers, output the largest number from the set of numbers with the fewest digits.

The input list will not be in any particular order and may contain repeated values.

Examples:

```<code>[1] -> 1
[9] -> 9
[1729] -> 1729
[1, 1] -> 1
[34, 3] -> 3
[38, 39] -> 39
[409, 12, 13] -> 13
[11, 11, 11, 1] -> 1
[11, 11, 11, 11] -> 11
[78, 99, 620, 1] -> 1
[78, 99, 620, 10] -> 99
[78, 99, 620, 100] -> 99
[1, 5, 9, 12, 63, 102] -> 9
[3451, 29820, 2983, 1223, 1337] -> 3451
[738, 2383, 281, 938, 212, 1010] -> 938
</code>```

The shortest code in bytes wins.

答:
Ruby, 34 bytes

```<code>->a{a.max_by{|n|[-n.to_s.size,n]}}
</code>```

See it on eval.in: https://eval.in/643153

Body:
Ruby, 34 bytes

->a{a.max_by{|n|[-n.to_s.size,n]}}

See it on eval.in: https://eval.in/643153


答:
MATL, 14 bytes

```<code>10&YlktX<=G*X>
</code>```

Try it online!

Explanation:

```<code>  &Yl           % Log
10              % Base 10
     kt         % Floor and duplicate
       X<       % Find the smallest element
         =      % Filter out elements that do not equal the smallest element
          G     % Push the input again
           *    % Multiply (this sets numbers that do not have the fewest digits to 0)
            X>  % And take the maximum
</code>```

Title: Output the largest number with the fewest digits

Body:
Given a nonempty list of positive decimal integers, output the largest number from the set of numbers with the fewest digits.

The input list will not be in any particular order and may contain repeated values.

Examples:

```<code>[1] -> 1
[9] -> 9
[1729] -> 1729
[1, 1] -> 1
[34, 3] -> 3
[38, 39] -> 39
[409, 12, 13] -> 13
[11, 11, 11, 1] -> 1
[11, 11, 11, 11] -> 11
[78, 99, 620, 1] -> 1
[78, 99, 620, 10] -> 99
[78, 99, 620, 100] -> 99
[1, 5, 9, 12, 63, 102] -> 9
[3451, 29820, 2983, 1223, 1337] -> 3451
[738, 2383, 281, 938, 212, 1010] -> 938
</code>```

The shortest code in bytes wins.

Body:
MATL, 14 bytes

10&YlktX<=G*X>

Try it online!

Explanation:

  &Yl           % Log
10              % Base 10
     kt         % Floor and duplicate
       X<       % Find the smallest element
         =      % Filter out elements that do not equal the smallest element
          G     % Push the input again
           *    % Multiply (this sets numbers that do not have the fewest digits to 0)
            X>  % And take the maximum


答:
Retina, 24 16 bytes

```O^`
O$#`
$.0
G1`
```

Try it online! or run all test cases.

Saved 8 bytes thanks to Martin!

The all test is using a slightly older version of the code, but the algorithm is identical. I'll update it to be closer when I get more time.

The trailing newline is significant. Sorts the numbers by reverse numeric value, then sorts them by number of digits. This leaves us with the largest number with the fewest digits in the first position, so we can just delete the remaining digits.

Body:
Retina, 24 16 bytes

O^`
O$#`
$.0
G1`

Try it online! or run all test cases.

Saved 8 bytes thanks to Martin!

The all test is using a slightly older version of the code, but the algorithm is identical. I'll update it to be closer when I get more time.

The trailing newline is significant. Sorts the numbers by reverse numeric value, then sorts them by number of digits. This leaves us with the largest number with the fewest digits in the first position, so we can just delete the remaining digits.


答:
JavaScript ES6, <s>80</s> <s>77</s> 70 bytes

```<code>a=>Math.max(...a.filter(l=>l.length==Math.min(...a.map(i=>i.length))))
</code>```

I hope I am going in the right direction...

Body:
JavaScript ES6, <s>80</s> <s>77</s> 70 bytes

a=>Math.max(...a.filter(l=>l.length==Math.min(...a.map(i=>i.length))))

I hope I am going in the right direction...


答:
Lua, 131 Bytes.

```<code>function(s)return s:gsub("%[%?%](%s*.)",function(a)return"a"..(a:find("[AEIOUaeiou]")and"n"or"")..a end):gsub("^.",string.upper)end
</code>```

Although lua is a terrible Language for golfing, I feel I've done pretty well.

Title: An A , or An An?

Body:
Lua, 131 Bytes.

function(s)return s:gsub("%[%?%](%s*.)",function(a)return"a"..(a:find("[AEIOUaeiou]")and"n"or"")..a end):gsub("^.",string.upper)end

Although lua is a terrible Language for golfing, I feel I've done pretty well.


答:
Python 2, <s>63</s> <s>30</s> 63 bytes

```<code>lambda a:a.sort()or[`i`for i in a if len(`i`)==len(`a[0]`)][-1]
</code>```

Body:
Python 2, <s>63</s> <s>30</s> 63 bytes

lambda a:a.sort()or[`i`for i in a if len(`i`)==len(`a[0]`)][-1]


答:
Perl 6, 18 bytes

*.min:{.chars,-$_}
```

<h2>Explanation:</h2>

<pre class="lang-perl6 prettyprint-override"><code>*\        # Whatever lambda
.min:     # find the minimum using

{         # bare block lambda with implicit parameter ｢$_｣

  .chars, # number of characters first ( implicit method call on ｢$_｣ )
  -$_     # then negative of the value in case of a tie
}
</code>```

Usage:

say [738, 2383, 281, 938, 212, 1010].&( *.min:{.chars,-$_} ); # 938

my &code = *.min:{.chars,-$_}

say code [78, 99, 620, 10]; # 99
```

Body:
Perl 6, 18 bytes

*.min:{.chars,-$_}

Explanation:

*\        # Whatever lambda
.min:     # find the minimum using

{         # bare block lambda with implicit parameter ｢$_｣

  .chars, # number of characters first ( implicit method call on ｢$_｣ )
  -$_     # then negative of the value in case of a tie
}

Usage:

say [738, 2383, 281, 938, 212, 1010].&( *.min:{.chars,-$_} ); # 938

my &code = *.min:{.chars,-$_}

say code [78, 99, 620, 10]; # 99


答:
Mathematica, <s>33</s> 31 bytes

```<code>Max@MinimalBy[#,IntegerLength]&
</code>```

MinimalBy selects all the elements of the original input list with the smallest score according to IntegerLength, i.e., with the smallest number of digits; and then Max outputs the largest one.

Thanks to Martin Ender for finding, and then saving, 2 bytes for me :)

Body:
Mathematica, <s>33</s> 31 bytes

Max@MinimalBy[#,IntegerLength]&

MinimalBy selects all the elements of the original input list with the smallest score according to IntegerLength, i.e., with the smallest number of digits; and then Max outputs the largest one.

Thanks to Martin Ender for finding, and then saving, 2 bytes for me :)


答:
Racket (with regex) 228 bytes

```<code>(define(r a b c)(regexp-replace* a b c))
(define(f s)
(set! s(r #rx"[a-zA-Z ]\\[\\?\\] (?=[aeiouAEIOU])"s" an "))
(set! s(r #rx"[a-zA-Z ]\\[\\?\\]"s" a"))
(set! s(r #rx"\\[\\?\\] (?=[aeiouAEIOU])"s"An "))
(r #rx"\\[\\?\\]"s"A"))
</code>```

Testing:

```<code>(f "[?] giant en le [?] sky.")
(f "[?] yarn ball?")
(f "[?] apple?")
(f "[?] hour ago I met [?] European. ")
(f "How about we build [?] big building. It will have [?] orange banana hanging out of [?] window.")
(f "Hello, this is [?] world!")
</code>```

Output:

```<code>"A giant en le a sky."
"A yarn ball?"
"An apple?"
"A hour ago I met an European. "
"How about we build a big building. It will have an orange banana hanging out of a window."
"Hello, this is a world!"
</code>```

Title: An A , or An An?

Body:
Racket (with regex) 228 bytes

(define(r a b c)(regexp-replace* a b c))
(define(f s)
(set! s(r #rx"[a-zA-Z ]\\[\\?\\] (?=[aeiouAEIOU])"s" an "))
(set! s(r #rx"[a-zA-Z ]\\[\\?\\]"s" a"))
(set! s(r #rx"\\[\\?\\] (?=[aeiouAEIOU])"s"An "))
(r #rx"\\[\\?\\]"s"A"))

Testing:

(f "[?] giant en le [?] sky.")
(f "[?] yarn ball?")
(f "[?] apple?")
(f "[?] hour ago I met [?] European. ")
(f "How about we build [?] big building. It will have [?] orange banana hanging out of [?] window.")
(f "Hello, this is [?] world!")

Output:

"A giant en le a sky."
"A yarn ball?"
"An apple?"
"A hour ago I met an European. "
"How about we build a big building. It will have an orange banana hanging out of a window."
"Hello, this is a world!"


答:
Pyth, <s>7</s> <s>3</s> 6 bytes

```<code>eS.ml`
</code>```

Test Suite

Explanation:

```<code>e      Still grab the last element
 S      Still sort
  .ml`   But prefilter the list for those with the (m)inimum length.
</code>```

7 byte solution:

```<code>eSh.gl`
</code>```

Test Suite

Explanation:

```<code>   .g   Group items in (implicit) input by:
     l  The length of
      ` their representation
  h     Get those with the shortest length
 S      Sort the resulting list
e       and grab the last (i.e. largest) element
</code>```

Body:
Pyth, <s>7</s> <s>3</s> 6 bytes

eS.ml`

<a href="http://pyth.herokuapp.com/?code=eS.ml%60&test_suite=1&test_suite_input=%5B1%5D%0A%5B9%5D%0A%5B1729%5D%0A%5B1%2C+1%5D%0A%5B34%2C+3%5D%0A%5B38%2C+39%5D%0A%5B409%2C+12%2C+13%5D%0A%5B11%2C+11%2C+11%2C+1%5D%0A%5B11%2C+11%2C+11%2C+11%5D%0A%5B78%2C+99%2C+620%2C+1%5D%0A%5B78%2C+99%2C+620%2C+10%5D%0A%5B78%2C+99%2C+620%2C+100%5D%0A%5B1%2C+5%2C+9%2C+12%2C+63%2C+102%5D%0A%5B3451%2C+29820%2C+2983%2C+1223%2C+1337%5D%0A%5B738%2C+2383%2C+281%2C+938%2C+212%2C+1010%5D&debug=0" rel="nofollow noreferrer">Test Suite

Explanation:

e      Still grab the last element
 S      Still sort
  .ml`   But prefilter the list for those with the (m)inimum length.

7 byte solution:

eSh.gl`

<a href="http://pyth.herokuapp.com/?code=eSh.gl%60&test_suite=1&test_suite_input=%5B1%5D%0A%5B9%5D%0A%5B1729%5D%0A%5B1%2C+1%5D%0A%5B34%2C+3%5D%0A%5B38%2C+39%5D%0A%5B409%2C+12%2C+13%5D%0A%5B11%2C+11%2C+11%2C+1%5D%0A%5B11%2C+11%2C+11%2C+11%5D%0A%5B78%2C+99%2C+620%2C+1%5D%0A%5B78%2C+99%2C+620%2C+10%5D%0A%5B78%2C+99%2C+620%2C+100%5D%0A%5B1%2C+5%2C+9%2C+12%2C+63%2C+102%5D%0A%5B3451%2C+29820%2C+2983%2C+1223%2C+1337%5D%0A%5B738%2C+2383%2C+281%2C+938%2C+212%2C+1010%5D&debug=0" rel="nofollow noreferrer">Test Suite

Explanation:

   .g   Group items in (implicit) input by:
     l  The length of
      ` their representation
  h     Get those with the shortest length
 S      Sort the resulting list
e       and grab the last (i.e. largest) element


答:
Python 2, 58 bytes

```<code>def F(x):l={len(`i`):i for i in sorted(x)};print l[min(l)]
</code>```

Body:
Python 2, 58 bytes

def F(x):l={len(`i`):i for i in sorted(x)};print l[min(l)]


答:
Jelly, 8 bytes

```<code>DL€İMị¹Ṁ
</code>```

Try it online! or Verify all test cases.

Explanation

```<code>DL€İMị¹Ṁ  Input: list A
D         Convert each integer to a list of base 10 digits
 L€       Get the length of each list (number of digits of each)
   İ      Take the reciprocal of each
    M     Get the indices of the maximal values
      ¹   Get A
     ị    Select the values at those indices from A
       Ṁ  Find the maximum and return
</code>```

Body:
Jelly, 8 bytes

DL€İMị¹Ṁ

Try it online! or Verify all test cases.

Explanation

DL€İMị¹Ṁ  Input: list A
D         Convert each integer to a list of base 10 digits
 L€       Get the length of each list (number of digits of each)
   İ      Take the reciprocal of each
    M     Get the indices of the maximal values
      ¹   Get A
     ị    Select the values at those indices from A
       Ṁ  Find the maximum and return


答:
J, <s>21</s> 14 bytes

Saved 7 bytes thanks to miles and (indirectly) Jonathan!

```<code>{.@/:#@":"0,.-
</code>```

This is a four-chain:

```<code>{.@/: (#@":"0 ,. -)
</code>```

Let's walk over the input 10 27 232 1000. The inner fork consists of three tines. #@":"0 calculates the sizes, ,. concats each size with its negated (-) member. For input 10 27 232 1000, we are left with this:

```<code>   (#@":"0 ,. -) 10 27 232 1000
2   _10
2   _27
3  _232
4 _1000
</code>```

Now, we have {.@/: as the outer tine. This is monadic first ({.) over dyadic sort (/:). That is, we'll be taking the first element of the result of dyadic /:. This sorts its right argument according to its left argument, which gives us for our input:

```<code>   (/: #@":"0 ,. -) 10 27 232 1000
27 10 232 1000
</code>```

Then, using {. gives us the first element of that list, and we are done:

```<code>   ({.@/: #@":"0 ,. -) 10 27 232 1000
27
</code>```

Old version

```<code>>./@(#~]=<./@])#@":"0
</code>```

Still working on improvements. I golfed it down from 30, and I think this is good enough. I'm going to first break it down into basic parts:

```<code>   size =: #@":"0
   max =: >./
   min =: <./
   over =: @
   right =: ]
   left =: [
   selectMin =: #~ right = min over right

   f =: max over selectMin size
   f 3 4 5
5
   f 3 4 53
4
   f 343 42 53
53
</code>```

Here's how this works.

```<code>>./@(#~ ] = <./@]) #@":"0
</code>```

This is a monadic train, but this part is a hook. The verb >./@(#~ ] = <./@]) is called with left argument as the input to the main chain and the sizes, defined as #@":"0, as the right argument. This is computed as length (#) over (@) default format (":), that is, numeric stringification, which is made to apply to the 0-cells (i.e. members) of the input ("0).

Let's walk over the example input 409 12 13.

```<code>   (#@":"0) 409 12 13
3 2 2
</code>```

Now for the inner verb, >./@(#~ ] = <./@]). It looks like >./@(...), which effectively means maximum value (>./) of (@) what's inside (...). As for the inside, this is a four-train, equivalent to this five-train:

```<code>[ #~ ] = <./@]
</code>```

[ refers to the original argument, and ] refers to the size array; 409 12 13 and 3 2 2 respectively in this example. The right tine, <./@], computes the minimum size, 2 in this case. ] = <./@] is a boolean array of values equal to the minimum, 0 1 1 in this case. Finally, [ #~ ... takes values from the left argument according the right-argument mask. This means that elements that correspond to 0 are dropped and 1 retained. So we are left with 12 13. Finally, according to the above, the max is taken, giving us the correct result of 13, and we are done.

Body:
J, <s>21</s> 14 bytes

Saved 7 bytes thanks to miles and (indirectly) Jonathan!

{.@/:#@":"0,.-

This is a four-chain:

{.@/: (#@":"0 ,. -)

Let's walk over the input 10 27 232 1000. The inner fork consists of three tines. #@":"0 calculates the sizes, ,. concats each size with its negated (-) member. For input 10 27 232 1000, we are left with this:

   (#@":"0 ,. -) 10 27 232 1000
2   _10
2   _27
3  _232
4 _1000

Now, we have {.@/: as the outer tine. This is monadic first ({.) over dyadic sort (/:). That is, we'll be taking the first element of the result of dyadic /:. This sorts its right argument according to its left argument, which gives us for our input:

   (/: #@":"0 ,. -) 10 27 232 1000
27 10 232 1000

Then, using {. gives us the first element of that list, and we are done:

   ({.@/: #@":"0 ,. -) 10 27 232 1000
27

Old version

>./@(#~]=<./@])#@":"0

Still working on improvements. I golfed it down from 30, and I think this is good enough. I'm going to first break it down into basic parts:

   size =: #@":"0
   max =: >./
   min =: <./
   over =: @
   right =: ]
   left =: [
   selectMin =: #~ right = min over right

   f =: max over selectMin size
   f 3 4 5
5
   f 3 4 53
4
   f 343 42 53
53

Here's how this works.

>./@(#~ ] = <./@]) #@":"0

This is a monadic train, but this part is a hook. The verb >./@(#~ ] = <./@]) is called with left argument as the input to the main chain and the sizes, defined as #@":"0, as the right argument. This is computed as length (#) over (@) default format (":), that is, numeric stringification, which is made to apply to the 0-cells (i.e. members) of the input ("0).

Let's walk over the example input 409 12 13.

   (#@":"0) 409 12 13
3 2 2

Now for the inner verb, >./@(#~ ] = <./@]). It looks like >./@(...), which effectively means maximum value (>./) of (@) what's inside (...). As for the inside, this is a four-train, equivalent to this five-train:

[ #~ ] = <./@]

[ refers to the original argument, and ] refers to the size array; 409 12 13 and 3 2 2 respectively in this example. The right tine, <./@], computes the minimum size, 2 in this case. ] = <./@] is a boolean array of values equal to the minimum, 0 1 1 in this case. Finally, [ #~ ... takes values from the left argument according the right-argument mask. This means that elements that correspond to 0 are dropped and 1 retained. So we are left with 12 13. Finally, according to the above, the max is taken, giving us the correct result of 13, and we are done.


问:
Invert a boolean array
A nice simple one

Input

Given a boolean array (Or an acceptable alternative), you can assume the array will never be more than 32 elements long.

```<code>[false, false, true, false, false]
</code>```

Output

Invert every element of the array and output it.

```<code>[true, true, false, true, true]
</code>```

Rules

You can write a full program or just a function

Standard loopholes apply

Shortest code in bytes, per language, wins!

Test cases

```<code>Input:
[true, false]
Output:
[false, true]

Input: //Example of acceptable alternative
[0,1,1]
Output:
[1,0,0]
</code>```

答:
Clojure, 12 bytes

```<code>(map not x)
</code>```

as in:

```<code>(map not [true false true])
</code>```

=> (false true false)

Updating due to the objection that this is not a function or program:

```<code>#(map not %)
</code>```

Returns a function that nots anything passed to it.

Title: Invert a boolean array

Body:
Clojure, 12 bytes

(map not x)

as in:

(map not [true false true])

=> (false true false)

Updating due to the objection that this is not a function or program:

#(map not %)

Returns a function that nots anything passed to it.


答:
Python 3, 56 bytes

```<code>lambda a:sorted(sorted(a),key=lambda x:-len(str(x)))[-1]
</code>```

Uses a lambda in a lambda!

Python 2, 53 bytes

```<code>s=lambda a:sorted(sorted(a),key=lambda x:-len(`x`))[-1]
</code>```

Same but with backticks

Body:
Python 3, 56 bytes

lambda a:sorted(sorted(a),key=lambda x:-len(str(x)))[-1]

Uses a lambda in a lambda!

Python 2, 53 bytes

s=lambda a:sorted(sorted(a),key=lambda x:-len(`x`))[-1]

Same but with backticks


问:
Convert to Bibi-binary
Bibi-binary is a numeric system invented by Boby Lapointe in order to represent numbers in letters which pronunciation seems funny.

Your task is to convert decimal numbers into Bibi-binary!

Conversion

A number is converted to base 16 (hexadecimal) and each character is replaced by its Bibi-binary name:

```<code>0 = HO
1 = HA
2 = HE
3 = HI
4 = BO
5 = BA
6 = BE
7 = BI
8 = KO
9 = KA
A = KE
B = KI
C = DO
D = DA
E = DE
F = DI
</code>```

Let N be a positive integer (between 1 -> 2^31-1).
For every character in the hexadecimal representation of N, replace the character by its according Bibi-binary pair (the table above contains all the pairs).

Example

N = 156

H = (hexadecimal representation of N) --> 9C

9 --> KA, C --> DO

Thus the output is KADO.

Input & output

You will receive an positive 32-bit integer N, which you will have to turn into Bibi-binary.

You may (return, print, etc...) in any convenient format, but the pairs have to be connected! So KA DO wouldn't be okay, but KADO would.

Both, lowercase and uppercase are allowed.

Rules

No loopholes.

This is code-golf, so the shortest code wins.

Testcases

```<code>2048 -> KOHOHO
156 -> KADO
10000 -> HEBIHAHO
12 -> DO
</code>```

答:
Lua, 196 Bytes

```<code>function(n)s=""t={"H","B","K","D"}p={"O","A","E","I"}while n>0 do s=n%4 ..s n=math.floor(n/4)end s=("0"):rep(#s%2)..s o=nil return s:gsub(".",function(s)o=not o return o and t[s+1]or p[s+1]end)end
</code>```

Lua is annoying for this sort of a task, as it doesn't per default contain a hex or binary conversion method. Most of the flesh is converting it to base 4. After that we force a 0 behind it if we need to using s=("0"):rep(#s%2), then we using gsub replace all the didgets with with their BIBI counterpart.

Title: Convert to Bibi-binary

Body:
Lua, 196 Bytes

function(n)s=""t={"H","B","K","D"}p={"O","A","E","I"}while n>0 do s=n%4 ..s n=math.floor(n/4)end s=("0"):rep(#s%2)..s o=nil return s:gsub(".",function(s)o=not o return o and t[s+1]or p[s+1]end)end

Lua is annoying for this sort of a task, as it doesn't per default contain a hex or binary conversion method. Most of the flesh is converting it to base 4. After that we force a 0 behind it if we need to using s=("0"):rep(#s%2), then we using gsub replace all the didgets with with their BIBI counterpart.


答:
Python 2, <s>48</s> 42 bytes

-6 bytes thanks to @Dennis (use min rather than sorted)

lambda l:min(l,key=lambda x:(len(`x`),-x))
```

All test cases are at ideone

Take the minimum of the list by (length, -value)

Body:
Python 2, <s>48</s> 42 bytes

-6 bytes thanks to @Dennis (use min rather than sorted)

lambda l:min(l,key=lambda x:(len(`x`),-x))

All test cases are at ideone

Take the minimum of the list by (length, -value)


答:
Jelly, 7 bytes

```<code>DL,NµÞḢ
</code>```

Test it at TryItOnline

Or see all test cases also at TryItOnline

How?

```<code>DL,NµÞḢ - Main link takes one argument, the list, e.g. [738, 2383, 281, 938, 212, 1010]
D       - convert to decimal, e.g. [[7,3,8],[2,3,8,3],[2,8,1],[9,3,8],[2,1,2],[1,0,1,0]]
 L      - length, e.g. [3,4,3,3,3,4]
   N    - negate, e.g [-738, -2383, -281, -938, -212, -1010]
  ,     - pair, e.g. [[3,-738],[4,-2383],[3,-281],[3,-938],[3,-212],[4,-1010]]
    µ   - make a monadic chain
     Þ  - sort the input by that monadic function, e.g [938,738,281,212,2383,1010]
          (the lists in the example are not created, but we sort over the values shown)
      Ḣ - pop and return the first element, e.g. 938
</code>```

Body:
Given a nonempty list of positive decimal integers, output the largest number from the set of numbers with the fewest digits.

The input list will not be in any particular order and may contain repeated values.

Examples:

```<code>[1] -> 1
[9] -> 9
[1729] -> 1729
[1, 1] -> 1
[34, 3] -> 3
[38, 39] -> 39
[409, 12, 13] -> 13
[11, 11, 11, 1] -> 1
[11, 11, 11, 11] -> 11
[78, 99, 620, 1] -> 1
[78, 99, 620, 10] -> 99
[78, 99, 620, 100] -> 99
[1, 5, 9, 12, 63, 102] -> 9
[3451, 29820, 2983, 1223, 1337] -> 3451
[738, 2383, 281, 938, 212, 1010] -> 938
</code>```

The shortest code in bytes wins.

Body:
Jelly, 7 bytes

DL,NµÞḢ

Test it at TryItOnline

Or see all test cases also at TryItOnline

How?

DL,NµÞḢ - Main link takes one argument, the list, e.g. [738, 2383, 281, 938, 212, 1010]
D       - convert to decimal, e.g. [[7,3,8],[2,3,8,3],[2,8,1],[9,3,8],[2,1,2],[1,0,1,0]]
 L      - length, e.g. [3,4,3,3,3,4]
   N    - negate, e.g [-738, -2383, -281, -938, -212, -1010]
  ,     - pair, e.g. [[3,-738],[4,-2383],[3,-281],[3,-938],[3,-212],[4,-1010]]
    µ   - make a monadic chain
     Þ  - sort the input by that monadic function, e.g [938,738,281,212,2383,1010]
          (the lists in the example are not created, but we sort over the values shown)
      Ḣ - pop and return the first element, e.g. 938


问:
C: replace AES FIPS-197 SubBytes table by constant-time code
In FIPS-197 (the Advanced Encryption Standard, known as AES), it is made heavy use of SubBytes, which could be implemented as

```<code>unsigned char SubBytes(unsigned char x) {
static const unsigned char t[256] = {
  0x63,0x7C,0x77,0x7B,0xF2,0x6B,0x6F,0xC5,0x30,0x01,0x67,0x2B,0xFE,0xD7,0xAB,0x76,
  0xCA,0x82,0xC9,0x7D,0xFA,0x59,0x47,0xF0,0xAD,0xD4,0xA2,0xAF,0x9C,0xA4,0x72,0xC0,
  0xB7,0xFD,0x93,0x26,0x36,0x3F,0xF7,0xCC,0x34,0xA5,0xE5,0xF1,0x71,0xD8,0x31,0x15,
  0x04,0xC7,0x23,0xC3,0x18,0x96,0x05,0x9A,0x07,0x12,0x80,0xE2,0xEB,0x27,0xB2,0x75,
  0x09,0x83,0x2C,0x1A,0x1B,0x6E,0x5A,0xA0,0x52,0x3B,0xD6,0xB3,0x29,0xE3,0x2F,0x84,
  0x53,0xD1,0x00,0xED,0x20,0xFC,0xB1,0x5B,0x6A,0xCB,0xBE,0x39,0x4A,0x4C,0x58,0xCF,
  0xD0,0xEF,0xAA,0xFB,0x43,0x4D,0x33,0x85,0x45,0xF9,0x02,0x7F,0x50,0x3C,0x9F,0xA8,
  0x51,0xA3,0x40,0x8F,0x92,0x9D,0x38,0xF5,0xBC,0xB6,0xDA,0x21,0x10,0xFF,0xF3,0xD2,
  0xCD,0x0C,0x13,0xEC,0x5F,0x97,0x44,0x17,0xC4,0xA7,0x7E,0x3D,0x64,0x5D,0x19,0x73,
  0x60,0x81,0x4F,0xDC,0x22,0x2A,0x90,0x88,0x46,0xEE,0xB8,0x14,0xDE,0x5E,0x0B,0xDB,
  0xE0,0x32,0x3A,0x0A,0x49,0x06,0x24,0x5C,0xC2,0xD3,0xAC,0x62,0x91,0x95,0xE4,0x79,
  0xE7,0xC8,0x37,0x6D,0x8D,0xD5,0x4E,0xA9,0x6C,0x56,0xF4,0xEA,0x65,0x7A,0xAE,0x08,
  0xBA,0x78,0x25,0x2E,0x1C,0xA6,0xB4,0xC6,0xE8,0xDD,0x74,0x1F,0x4B,0xBD,0x8B,0x8A,
  0x70,0x3E,0xB5,0x66,0x48,0x03,0xF6,0x0E,0x61,0x35,0x57,0xB9,0x86,0xC1,0x1D,0x9E,
  0xE1,0xF8,0x98,0x11,0x69,0xD9,0x8E,0x94,0x9B,0x1E,0x87,0xE9,0xCE,0x55,0x28,0xDF,
  0x8C,0xA1,0x89,0x0D,0xBF,0xE6,0x42,0x68,0x41,0x99,0x2D,0x0F,0xB0,0x54,0xBB,0x16};
return t[x];}
</code>```

This function is not arbitrary; it is a reversible mapping, consisting of an inversion in a Galois Field followed by an affine transformation. All the details are in FIPS-197 section 5.1.1 or here section 4.2.1 (under a slightly different name).

One problem with implementation as a table is that it opens to so-called cache-timing attacks.

Thus your mission is to devise an exact replacement for the above SubBytes() function, that exhibits constant-time behavior; we'll assume that's the case when nothing depending on the input x of SubBytes is used  either:

as an array index,

as the control operand of if, while, for, case, or operator ?:;

as any operand of operators &&, ||, !, ==, !=, <, >, <=, >=, *, /, %;

as the right operand of operators >>, <<, *=, /=, %=, <<=, >>=.

The winning entry will be one with the lowest cost, obtained from the number of operators executed in the input-dependent data path, with a weight of 5 for unary operators - and ~ as well as for <<1, >>1, +1, -1; weight of 7 for all other operators, shifts with other counts, or adds/subs of other constants (type casts and promotions are free). By principle, that cost is unchanged by unrolling loops (if any), and independent of the input x. As a tie-breaker, the answer with the shortest code after removing whitespace and comments wins.

I plan to designate an entry as answer as early as I can in year 2013, UTC. I will consider answers in languages that I've some knowledge of, ranking them as a straight translation to C not optimized for size.

Apologies for the initial omission of +1 and -1 in the favored operators, of free casts and promotions, and ranking of size. Note that * is prohibited both when unary, and as multiplication.

Body:
Score: 940 933 926 910, field tower approach

public class SBox2
{
    public static void main(String[] args)
    {
        for (int i = 0; i < 256; i++) {
            int s = SubBytes(i);
            System.out.format("%02x  ", s);
            if (i % 16 == 15) System.out.println();
        }
    }

    private static int SubBytes(int x) {
        int fwd;
        fwd  = 0x010001 & -(x & 1); x >>= 1; //   7+5+7+5+ | 24+
        fwd ^= 0x1d010f & -(x & 1); x >>= 1; // 7+7+5+7+5+ | 31+
        fwd ^= 0x4f020b & -(x & 1); x >>= 1; // 7+7+5+7+5+ | 31+
        fwd ^= 0x450201 & -(x & 1); x >>= 1; // 7+7+5+7+5+ | 31+
        fwd ^= 0xce080d & -(x & 1); x >>= 1; // 7+7+5+7+5+ | 31+
        fwd ^= 0xa20f0f & -(x & 1); x >>= 1; // 7+7+5+7+5+ | 31+
        fwd ^= 0xc60805 & -(x & 1); x >>= 1; // 7+7+5+7+5+ | 31+
        fwd ^= 0x60070e & -x;                // 7+7+5+     | 19+

        // Running total so far: 229

        int p1;
        {
            int ma = fwd;
            int mb = fwd >> 16;         // 7+         | 7+
            p1  = ma & -(mb&1); ma<<=1; //   7+5+7+5+ | 24+
            p1 ^= ma & -(mb&2); ma<<=1; // 7+7+5+7+5+ | 31+
            p1 ^= ma & -(mb&4); ma<<=1; // 7+7+5+7+5+ | 31+
            p1 ^= ma & -(mb&8);         // 7+7+5+7+   | 26+
            int t = p1 >> 3;            // 7+         | 7+
            p1 ^= (t >> 1) ^ (t & 0xe); // 7+5+7+7+   | 26+
        }

        // Running total so far: 229 + 152 = 381

        int y3, y2, y1, y0;
        {
            int Kinv = (fwd >> 20) ^ p1;     // 7+7+
            int w0 = Kinv & 1; Kinv >>= 1;   // 7+5+
            int w1 = Kinv & 1; Kinv >>= 1;   // 7+5+
            int w2 = Kinv & 1; Kinv >>= 1;   // 7+5+
            int w3 = Kinv & 1;               // 7+

            int t0 = w1 ^ w0 ^ (w2 & w3);      // 7+7+7+
            int t1 = w2 ^ (w0 | w3);           // 7+7+
            int t2 = t0 ^ t1;                  // 7+

            y3 = t2 ^ (t1 & (w1 & w3));        // 7+7+7+
            y2 = t0 ^ (w0 | t2);               // 7+7+
            y1 = w0 ^ w3 ^ (t1 & t0);          // 7+7+7+
            y0 = w3 ^ (t0 | (w1 ^ (w0 | w2))); // 7+7+7+7

        }

        // Running total so far: 381 + 24*7 + 3*5 = 564

        int p2;
        {
            int ma = fwd;
            p2  = ma & -y0; ma<<=1;       //   7+5+5+ | 17+
            p2 ^= ma & -y1; ma<<=1;       // 7+7+5+5+ | 24+
            p2 ^= ma & -y2; ma<<=1;       // 7+7+5+5+ | 24+
            p2 ^= ma & -y3;               // 7+7+5+   | 19+
            int t = p2 >> 3;              // 7+       | 7+
            p2 ^= (t >> 1) ^ (t & 0xe0e); // 7+5+7+7+ | 26
        }

        // Running total so far: 564 + 117 = 681

        int inv8;
        inv8  =  31 & -(p2 & 1);           //   7+5+7+   | 19+
        inv8 ^= 178 & -(p2 & 2); p2 >>= 2; // 7+7+5+7+7+ | 33+
        inv8 ^= 171 & -(p2 & 1);           // 7+7+5+7+   | 26+
        inv8 ^=  54 & -(p2 & 2); p2 >>= 6; // 7+7+5+7+7+ | 33+
        inv8 ^= 188 & -(p2 & 1);           // 7+7+5+7+   | 26+
        inv8 ^=  76 & -(p2 & 2); p2 >>= 2; // 7+7+5+7+7+ | 33+
        inv8 ^= 127 & -(p2 & 1);           // 7+7+5+7+   | 26+
        inv8 ^= 222 & -(p2 & 2);           // 7+7+5+7    | 26+

        return inv8 ^ 0x63;                // 7+         | 7+

        // Grand total: 681 + 229 = 910
    }
}

The structure is essentially the same as Boyar and Peralta's implementation - reduce inversion in GF(2^8) to inversion in GF(2^4), break it down into a linear prologue, a non-linear body, and a linear epilogue, and then minimise them separately. I pay some penalties for bit extraction, but I compensate by being able to do operations in parallel (with some judicious padding of the bits of fwd). In more detail...

Background

As mentioned in the problem description, the S-box consists of an inversion in a particular implementation of the Galois field GF(2^8) followed by an affine transformation. If you know what both of those mean, skip this section.

An affine (or linear) transformation is a function f(x) which respects f(x + y) = f(x) + f(y) and f(a*x) = a*f(x).

A field is a set F of elements with two special elements, which we'll call 0 and 1, and two operators, which we'll call + and *, which respects various properties. In this section, assume that x, y, and z are elements of F.

The elements of F form an abelian group under + with 0 as the identity: i.e. x + y is an element of F; x + 0 = 0 + x = x; each x has a corresponding -x such that x + (-x) = (-x) + x = 0; x + (y + z) = (x + y) + z; and x + y = y + x.

The elements of F other than 0 form an abelian group under * with 1 as the identity.

Multiplication distributes over addition: x * (y + z) = (x * y) + (x * z).

It turns out that there are some quite severe limitations on finite fields:

They must have a number of elements which is a power of a prime.

They are isomorphic with all other finite fields of the same size (i.e. there's really only one finite field of a given size, and any others are just relabellings; call that field GF(p^k) where p is the prime and k is the power).

The multiplicative group F\{0} under * is cyclic; i.e. there's at least one element g such that every element is a power of g.

For powers greater than 1 there is a representation as univariate polynomials of order k of the field of the prime order. E.g. GF(2^8) has a representation in terms of polynomials of x over GF(2). In fact there's usually more than one representation. Consider x^7 * x in GF(2^8); it must be equivalent to some order-7 polynomial, but which? There are a lot of choices which give the right structure; AES chooses to make x^8 = x^4 + x^3 + x + 1 (the lexicographically smallest polynomial which works).

So how do we compute an inverse in that particular representation of GF(2^8)? It's too chunky a problem to tackle directly, so we need to break it down.

Field towers: representing GF(2^8) in terms of GF(2^4)

Instead of representing GF(2^8) with polynomials of 8 terms over GF(2) we can represent it with polynomials of 2 terms over GF(2^4). This time we need to choose a linear polynomial for x^2. Suppose we choose x^2 = px + q. Then (ax + b) * (cx + d) = (ad + bc + acp)x + (bd + acq).

Is it easier to find an inverse in this representation? If (cx + d) = (ax + b)^-1 we get the simultaneous equations

ad + (b + ap)c = 0

bd +     (aq)c = 1

Let D = [b(b+ap) + a^2 q] and set c = a * D^-1; d = (b + ap) * D^-1. So we can do an inverse in GF(2^8) for the cost of a conversion to GF(2^4), an inverse and a few additions and multiplications in GF(2^4), and a conversion back. Even if we do the inverse by means of a table, we've reduced the table size from 256 to 16.

Implementation details

To construct a representation of GF(4) we can choose between three polynomials to reduce x^4:

x^4 = x + 1

x^4 = x^3 + 1

x^4 = x^3 + x^2 + x + 1

The most important difference is in the implementation of multiplication. For any of the three (which correspond to poly of 3, 9, f) the following will work:

// 14x &, 7x unary -, 3x <<1, 3x >>1, 3x >>3, 6x ^ gives score 226
int mul(int a, int b) {
    // Call current values a = a0, b = b0
    int p = a & -(b & 1);
    a = ((a << 1) ^ (poly & -(a >> 3))) & 15;
    b >>= 1;
    // Now p = a0 * (b0 mod x); a = a0 x; b = b0 div x

    p ^= a & -(b & 1);
    a = ((a << 1) ^ (poly & -(a >> 3))) & 15;
    b >>= 1;
    // Now p = a0 * (b0 mod x^2); a = a0 x^2; b = b0 div x^2

    p ^= a & -(b & 1);
    a = ((a << 1) ^ (poly & -(a >> 3))) & 15;
    b >>= 1;
    // Now p = a0 * (b0 mod x^3); a = a0 x^3; b = b0 div x^3

    p ^= a & -(b & 1);
    // p = a0 * b0

    return p;
}

However, if we choose poly = 3 we can handle the overflow much more efficiently because it has a nice structure: there's no double-overflow, because the two inputs are both cubics and x^6 = x^2 (x + 1) is also cubic. In addition we can save the shifts of b: since we're leaving the overflow to last, a0 x^2 doesn't have any set bits corresponding to x or 1 and so we can mask it with -4 instead of -1. The result is

// 10x &, 4x unary -, 3x <<1, 1x >>1, 1x >>3, 5x ^ gives score 152
int mul(int a, int b) {
    int p;
    p  = a & -(b & 1); a <<= 1;
    p ^= a & -(b & 2); a <<= 1;
    p ^= a & -(b & 4); a <<= 1;
    p ^= a & -(b & 8);
    // Here p = a0 * b0 but with overflow, which we need to bring back down.

    int t = p >> 3;
    p ^= (t >> 1) ^ (t & 0xe);
    return p & 15;
}

We still need to choose the values of p and q for the representation of GF(2^8) over GF(2^4), but we don't have many constraints on them. The one thing that matters is that we can get a linear function from the bits of our original representation to the bits of the working representation. This matters for two reasons: firstly, it's easy to do linear transformations, whereas a non-linear transformation would require optimisation equivalent in difficulty to just optimising the entire S-box; secondly, because we can get some side benefits. To recap the structure:

GF256 SubBytes(GF256 x) {
    GF16 a, b, t, D, Dinv, c, d;

    (a, b) = f(x); // f is linear

    t = b + a * p;
    D = b * t + a * a * q;
    Dinv = inverse_GF16(D);
    c = a * Dinv;
    d = t * Dinv;

    return finv(c, d); // finv is also linear
}

If the bits of x are x7 x6 ... x0 then since the transform is linear we get a = f({x7}0000000 + 0{x6}000000 + ... + 0000000{x0}) = f({x7}0000000) + f(0{x6}000000) + ... + f(0000000{x0}). Square it and we get a^2 = f({x7}0000000)^2 + f(0{x6}000000)^2 + ... + f(0000000{x0})^2 where the cross-terms cancel (because in GF(2), 1 + 1 = 0). So a^2 can also be computed as a linear function of x. We can augment the forward linear transform to get:

GF256 SubBytes(GF256 x) {
    GF16 a, b, t, a2q, D, Dinv, c, d;

    (a, b, t, a2q) = faug(x);

    D = b * t + a2q;
    Dinv = inverse_GF16(D);
    c = a * Dinv;
    d = t * Dinv;

    return finv(c, d);
}

and we're down to three multiplications and one addition. We can also extend the multiplication code to do the two multiplications by Dinv in parallel. So our total cost is a forward linear transformation, an addition, two multiplications, an inverse in GF(2^4), and a back linear transformation. We can roll in the post-inverse linear transformation of the S-box and get that essentially for free.

The computation of the coefficients for the linear transformations isn't very interesting, and nor is the micro-optimisation to save a mask here and a shift there. The remaining interesting part is the optimisation of inverse_GF16. There are 2^64 different functions from 4 bits to 4 bits, so a direct optimisation requires lots of memory and time. What I've done is to consider 4 functions from 4 bits to 1 bit, place a cap on the total cost permitted for any one function (with a maximum cost of 63 per function I can enumerate all suitable expressions in under a minute), and for each tuple of functions do common subexpression elimination. After 25 minutes of crunching, I find that the best inverse possible with that cap has a total cost of 133 (an average of 33.25 per bit of the output, which isn't bad considering that the cheapest expression for any individual bit is 35).

I'm still experimenting with other approaches to minimise the inversion in GF(2^4), and an approach which builds bottom-up rather than top-down has yielded an improvement from 133 to 126.


问:
Make me a scrolling marquee

Introduction

Remember the roaring 80's? I mean, you know, like 30 years ago? No cell phones, no internet, no ATM's, fluorescent clothing (what was that?!) and scrolling marqee's! No, no, no! Not the online ones, but real ones, With LED lights.

Since I'm in a nostalgic mood, I'd like you to create a scrolling marquee.

Challenge

Create a program where you can enter a one line string. You program needs to create a 80 character wide scrolling marquee, repeating the text if necessary.

Rules

The user must be able to enter a string to your program as input. The string can be a command line parameter or a string entered while running the program.

Your program must continuously print a string of exactly 80 (visible) characters.

The string must be updated every 0.1 second (more or less; I won't be timing it), shifting the characters every iteration one position to the left.

The string "rotates". At the end of the user supplied string, another instance of the string must appear.

You program must print it's output on one line, without linefeeds (use a '\r' instead of a '\n')

Your program must run ad infinitum, until an user interrupt.

This is a codegolf, so shortest code in bytes wins.

There is a 10% bonus (rounded up to the next integer) for printing in red on a black background.

Standard loopholes apply.

Reference implementation in Python 2.7

This program isn't golfed, but it provides a reference implementation (and thus an upper limit to the size).

```<code>import time,sys
s=raw_input()*99
while 1:
    for i in range(80):
        print s[i:i+80]+'\r',
        sys.stdout.flush()
        time.sleep(0.1)
</code>```

答:
LOVE2D Lua, 197-10% = 178 Bytes

```<code>f=io.open("t.t"):read().."  "love.graphics.setColor(255,0,0)love.window.setMode(640,14)function love.draw()s=""for i=1,80 do n=i+os.clock()s=s..f:sub(n%#f,n%#f) end love.graphics.print(s,0,0)end
</code>```

Requires the input to be in a file called 't.t' in the root, thus 3 extra bytes were added to the score.

Really basic in functionality, just in a for loop of 80 iterations, append the character at index of i plus the current time in seconds modulated by the length of the current string, giving a repeated 80 character long string of the input, which shifts left as time goes on.

I used LOVE2D For the laughs.

Title: Make me a scrolling marquee

Body:
LOVE2D Lua, 197-10% = 178 Bytes

f=io.open("t.t"):read().."  "love.graphics.setColor(255,0,0)love.window.setMode(640,14)function love.draw()s=""for i=1,80 do n=i+os.clock()s=s..f:sub(n%#f,n%#f) end love.graphics.print(s,0,0)end

Requires the input to be in a file called 't.t' in the root, thus 3 extra bytes were added to the score.

Really basic in functionality, just in a for loop of 80 iterations, append the character at index of i plus the current time in seconds modulated by the length of the current string, giving a repeated 80 character long string of the input, which shifts left as time goes on.

I used LOVE2D For the laughs.


答:
Pip, 11 bytes

```<code>(SNgSK-#_v)
</code>```

Takes input as command-line args. Try it online!

First time using the Sort-Keyed operator! Like Python's sorted(), it takes a function that is applied to each item of the iterable and the result used as a sort key. Here's how this program works:

```<code> SNg         List of cmdline args, sorted numerically in increasing order
    SK       Sort with key function...
      -#_    ... negative length(x), thus putting the shortest numbers at the end but not
               affecting the relative ordering among numbers with the same length
(        v)  Get the last element (index -1) and auto-print
</code>```

Body:
Pip, 11 bytes

(SNgSK-#_v)

Takes input as command-line args. Try it online!

First time using the Sort-Keyed operator! Like Python's sorted(), it takes a function that is applied to each item of the iterable and the result used as a sort key. Here's how this program works:

 SNg         List of cmdline args, sorted numerically in increasing order
    SK       Sort with key function...
      -#_    ... negative length(x), thus putting the shortest numbers at the end but not
               affecting the relative ordering among numbers with the same length
(        v)  Get the last element (index -1) and auto-print


Body:
JavaScript (ES6), 62 bytes

var solution =

a=>a.map(n=>(l=`${n}`.length)>a?l>a+1|n<r?0:r=n:(a=l-1,r=n))|r

;document.write('<pre>' + `
[1] -> 1
[9] -> 9
[1729] -> 1729
[1, 1] -> 1
[34, 3] -> 3
[38, 39] -> 39
[409, 12, 13] -> 13
[11, 11, 11, 1] -> 1
[11, 11, 11, 11] -> 11
[78, 99, 620, 1] -> 1
[78, 99, 620, 10] -> 99
[78, 99, 620, 100] -> 99
[1, 5, 9, 12, 63, 102] -> 9
[3451, 29820, 2983, 1223, 1337] -> 3451
[738, 2383, 281, 938, 212, 1010] -> 938
`.split('\n').slice(1, -1).map(c =>
  c + ', result: ' + solution(eval(c.slice(0, c.indexOf('->'))))
).join('\n'))


答:
Actually, 2 bytes

```<code>♂Y
</code>```

Try it online!

Map (♂) Boolean negate (Y)

Title: Invert a boolean array

Body:
A nice simple one

Input

Given a boolean array (Or an acceptable alternative), you can assume the array will never be more than 32 elements long.

```<code>[false, false, true, false, false]
</code>```

Output

Invert every element of the array and output it.

```<code>[true, true, false, true, true]
</code>```

Rules

You can write a full program or just a function

Standard loopholes apply

Shortest code in bytes, per language, wins!

Test cases

```<code>Input:
[true, false]
Output:
[false, true]

Input: //Example of acceptable alternative
[0,1,1]
Output:
[1,0,0]
</code>```

Body:
Actually, 2 bytes

♂Y

Try it online!

Map (♂) Boolean negate (Y)


答:
Clojure, 63 bytes

```<code>(reduce #(if(=(quot %1 10)(quot %2 10))(max %1 %2) %1)(sort x))
</code>```

as in:

```<code>(reduce #(if(=(quot %1 10)(quot %2 10))(max %1 %2) %1)(sort[3 7 121 11 8 2 10 9]))
=> 9
</code>```

Though I'm sure there's a way to make it smaller.

Body:
Clojure, 63 bytes

(reduce #(if(=(quot %1 10)(quot %2 10))(max %1 %2) %1)(sort x))

as in:

(reduce #(if(=(quot %1 10)(quot %2 10))(max %1 %2) %1)(sort[3 7 121 11 8 2 10 9]))
=> 9

Though I'm sure there's a way to make it smaller.


问:
Print the alphabet without using each vowel
Inspiration: in 1939, a man named Ernest Vincent Wright wrote a novel called Gadsby without using the letter 'e'.

Your task is to write a set of (up to 5) programs in any language (which has a text-based syntax*) to output all 26 letters of the alphabet in order.  However for each vowel aeiou, at least one of the programs must not include any occurrence of the vowel.

So there must be

a program that does not use 'a' or 'A' anywhere in the syntax of the program.

a program that does not use 'e' or 'E' anywhere in the syntax of the program.

a program that does not use 'i'  or 'I' anywhere in the syntax of the program.

a program that does not use 'o' or 'O' anywhere in the syntax of the program.

a program that does not use 'u' or 'U' anywhere in the syntax of the program.

All of them must output abcdefghijklmnopqrstuvwxyz.

The winner shall be the solution where the length of all programs is the shortest.

* since the constraint wouldn't be much of a challenge in Piet or Whitespace

答:
Brainfuck, 25 bytes

One byte improvement c/o Sp3000.

+[+<+<+[>]<-<+<+]>[+>+.<]
```

<p>Try it online!</p>

<p>The initial bit <code>+[+<+<+[>]<-<+<+]</code> initializes the tape to:</p>

<pre class="lang-default prettyprint-override"><code>[0, 106, 106, 0, 230, 96, 0, 135, 0]
              ^
</code>```

This is an ideal tape (as 230 is 256-26).

26 bytes

--[->-[<]>+>-]>[+++<<+.>>]
```

<p>Try it online!</p>

<p>Exactly one byte per letter. The initial bit <code>--[->-[<]>+>-]</code> initializes the tape to:</p>

<pre class="lang-default prettyprint-override"><code>[0, 0, 0, 0, 0, 96, 0, 178, 0]
                    ^
</code>```

178 is conveniently 256 - 26·3.

Alternatives

-[-[+>--<<<]>>>]>[->-.++<]
+[+[->++<<]>>+>+]<+[-<+.>]
```

Body:
Brainfuck, 25 bytes

One byte improvement c/o Sp3000.

+[+<+<+[>]<-<+<+]>[+>+.<]

Try it online!

The initial bit +[+<+<+[>]<-<+<+] initializes the tape to:

[0, 106, 106, 0, 230, 96, 0, 135, 0]
              ^

This is an ideal tape (as 230 is 256-26).

26 bytes

--[->-[<]>+>-]>[+++<<+.>>]

Try it online!

Exactly one byte per letter. The initial bit --[->-[<]>+>-] initializes the tape to:

[0, 0, 0, 0, 0, 96, 0, 178, 0]
                    ^

178 is conveniently 256 - 26·3.

Alternatives

-[-[+>--<<<]>>>]>[->-.++<]
+[+[->++<<]>>+>+]<+[-<+.>]


问:
Counterfeit Coins on a Pointer Scale
You sell gold coins. Each gold coin you sell is supposed to be 1 ounce. However, you find out that one of your coin suppliers is cheating you. By alloying the gold material with something else, their coins weigh only 0.9 ounces. With a help of a pointer scale (one that shows the exact weight of a quantity of matter set on it), you want to determine which of your coin suppliers is selling you the counterfeit coins.

Apparently, you are not the only one to have this problem - lots of gold sellers buy coins from this supplier, and the supplier knows that it is being dodgy and is changing their branding accordingly. All of these sellers have the same problem - 1 ounce coins that end up being 0.9 ounces from this supplier - and need to solve it, fast! How can you determine, out of n suppliers, which one is the cheating supplier with the minimum number of weighings on the pointer scale?

Your task is to write a program function that can solve this problem automatically for n suppliers. It's input includes:

an integer number of suppliers, n,

an oracle function that represents weighing a set of coins on the balance scale

It must take this information, calling this function a minimum number of times and returning, as output, the index number of the cheating supplier.

The oracle function has the following specifications:

It takes as input an int->int mapping (as an array or dictionary, whichever your language prefers) mapping each supplier index (from 0 to n-1) to a number of gold coins that you want to try weighing on the scale.

The returned output is the total weight, in ounces, of the coins put on the scale.

The function is in whatever format your language prefers for passing procedures as data. For instance, functional languages will pass lambdas, C will take a function pointer, Java 7 and earlier will take a functional interface. Languages that support none of these, but do support string execution, will take these as strings.

In those cases when the oracle can be stringified or otherwise inspected as data, you may assume that it is sufficiently obfuscated such that you cannot tell which supplier is cheating without executing it.

This is also code-golf: among the solutions that call the function the minimum number of times, the smallest solution in bytes is the winner!

NOTE: If your language does not support functions at all, but does support string execution, write your program as a standalone program - assume that the number of suppliers, followed by the oracle, will be passed into standard input. If your language does not support string execution, assume that a file path to a binary oracle will be provided instead.

答:
Python, 33 bytes

lambda n,f:n*~-n*5-f(range(n))*10
```

Puts 0 coins from supplier 0, 1 coin from supplier 1, ... n-1 coins from supplier n-1. The deficit is then 0.1 for each coin sent to the cheating supplier, so i/10. We therefore subtract the oracle value from the fair sum n*(n-1)/2 and multiply by 10. Distributing the *10 saved on parens for a shorter expression.

Title: Counterfeit Coins on a Pointer Scale

Body:
Python, 33 bytes

lambda n,f:n*~-n*5-f(range(n))*10

Puts 0 coins from supplier 0, 1 coin from supplier 1, ... n-1 coins from supplier n-1. The deficit is then 0.1 for each coin sent to the cheating supplier, so i/10. We therefore subtract the oracle value from the fair sum n*(n-1)/2 and multiply by 10. Distributing the *10 saved on parens for a shorter expression.


答:
Brachylog, 16 bytes

```<code>or:@]feL:la#=,Lh
</code>```

Try it online!

Explanation

```<code>or                 Sort the list in descending order.
  :@]f             Find all suffixes of the list.
      eL           Take one suffix L of the list.
        :la        Apply length to all numbers in that suffix.
           #=,     All lengths must be equal.
              Lh   Output is the first element of L.
</code>```

Body:
Brachylog, 16 bytes

or:@]feL:la#=,Lh

Try it online!

Explanation

or                 Sort the list in descending order.
  :@]f             Find all suffixes of the list.
      eL           Take one suffix L of the list.
        :la        Apply length to all numbers in that suffix.
           #=,     All lengths must be equal.
              Lh   Output is the first element of L.


答:
05AB1E, 5 bytes

Code:

```<code>({é¬(
</code>```

Explanation:

```<code>(      # Negate the list, e.g. [22, 33, 4] -> [-22, -33, -4]
 {     # Sort, e.g. [-22, -33, -4] -> [-33, -22, -4]
  é    # Sort by length, e.g. [-33, -22, -4] -> [-4, -22, -33]
   ¬   # Get the first element.
    (  # And negate that.
</code>```

Uses the CP-1252 encoding. Try it online!

Body:
05AB1E, 5 bytes

Code:

({é¬(

Explanation:

(      # Negate the list, e.g. [22, 33, 4] -> [-22, -33, -4]
 {     # Sort, e.g. [-22, -33, -4] -> [-33, -22, -4]
  é    # Sort by length, e.g. [-33, -22, -4] -> [-4, -22, -33]
   ¬   # Get the first element.
    (  # And negate that.

Uses the CP-1252 encoding. Try it online!


答:
Haskell, 39 bytes

```<code>snd.maximum.map((0-).length.show>>=(,))
</code>```

Body:
Haskell, 39 bytes

snd.maximum.map((0-).length.show>>=(,))


Title: C: replace AES FIPS-197 SubBytes table by constant-time code

Body:
In FIPS-197 (the Advanced Encryption Standard, known as AES), it is made heavy use of SubBytes, which could be implemented as

```<code>unsigned char SubBytes(unsigned char x) {
static const unsigned char t[256] = {
  0x63,0x7C,0x77,0x7B,0xF2,0x6B,0x6F,0xC5,0x30,0x01,0x67,0x2B,0xFE,0xD7,0xAB,0x76,
  0xCA,0x82,0xC9,0x7D,0xFA,0x59,0x47,0xF0,0xAD,0xD4,0xA2,0xAF,0x9C,0xA4,0x72,0xC0,
  0xB7,0xFD,0x93,0x26,0x36,0x3F,0xF7,0xCC,0x34,0xA5,0xE5,0xF1,0x71,0xD8,0x31,0x15,
  0x04,0xC7,0x23,0xC3,0x18,0x96,0x05,0x9A,0x07,0x12,0x80,0xE2,0xEB,0x27,0xB2,0x75,
  0x09,0x83,0x2C,0x1A,0x1B,0x6E,0x5A,0xA0,0x52,0x3B,0xD6,0xB3,0x29,0xE3,0x2F,0x84,
  0x53,0xD1,0x00,0xED,0x20,0xFC,0xB1,0x5B,0x6A,0xCB,0xBE,0x39,0x4A,0x4C,0x58,0xCF,
  0xD0,0xEF,0xAA,0xFB,0x43,0x4D,0x33,0x85,0x45,0xF9,0x02,0x7F,0x50,0x3C,0x9F,0xA8,
  0x51,0xA3,0x40,0x8F,0x92,0x9D,0x38,0xF5,0xBC,0xB6,0xDA,0x21,0x10,0xFF,0xF3,0xD2,
  0xCD,0x0C,0x13,0xEC,0x5F,0x97,0x44,0x17,0xC4,0xA7,0x7E,0x3D,0x64,0x5D,0x19,0x73,
  0x60,0x81,0x4F,0xDC,0x22,0x2A,0x90,0x88,0x46,0xEE,0xB8,0x14,0xDE,0x5E,0x0B,0xDB,
  0xE0,0x32,0x3A,0x0A,0x49,0x06,0x24,0x5C,0xC2,0xD3,0xAC,0x62,0x91,0x95,0xE4,0x79,
  0xE7,0xC8,0x37,0x6D,0x8D,0xD5,0x4E,0xA9,0x6C,0x56,0xF4,0xEA,0x65,0x7A,0xAE,0x08,
  0xBA,0x78,0x25,0x2E,0x1C,0xA6,0xB4,0xC6,0xE8,0xDD,0x74,0x1F,0x4B,0xBD,0x8B,0x8A,
  0x70,0x3E,0xB5,0x66,0x48,0x03,0xF6,0x0E,0x61,0x35,0x57,0xB9,0x86,0xC1,0x1D,0x9E,
  0xE1,0xF8,0x98,0x11,0x69,0xD9,0x8E,0x94,0x9B,0x1E,0x87,0xE9,0xCE,0x55,0x28,0xDF,
  0x8C,0xA1,0x89,0x0D,0xBF,0xE6,0x42,0x68,0x41,0x99,0x2D,0x0F,0xB0,0x54,0xBB,0x16};
return t[x];}
</code>```

This function is not arbitrary; it is a reversible mapping, consisting of an inversion in a Galois Field followed by an affine transformation. All the details are in FIPS-197 section 5.1.1 or here section 4.2.1 (under a slightly different name).

One problem with implementation as a table is that it opens to so-called cache-timing attacks.

Thus your mission is to devise an exact replacement for the above SubBytes() function, that exhibits constant-time behavior; we'll assume that's the case when nothing depending on the input x of SubBytes is used  either:

as an array index,

as the control operand of if, while, for, case, or operator ?:;

as any operand of operators &&, ||, !, ==, !=, <, >, <=, >=, *, /, %;

as the right operand of operators >>, <<, *=, /=, %=, <<=, >>=.

The winning entry will be one with the lowest cost, obtained from the number of operators executed in the input-dependent data path, with a weight of 5 for unary operators - and ~ as well as for <<1, >>1, +1, -1; weight of 7 for all other operators, shifts with other counts, or adds/subs of other constants (type casts and promotions are free). By principle, that cost is unchanged by unrolling loops (if any), and independent of the input x. As a tie-breaker, the answer with the shortest code after removing whitespace and comments wins.

I plan to designate an entry as answer as early as I can in year 2013, UTC. I will consider answers in languages that I've some knowledge of, ranking them as a straight translation to C not optimized for size.

Apologies for the initial omission of +1 and -1 in the favored operators, of free casts and promotions, and ranking of size. Note that * is prohibited both when unary, and as multiplication.

Body:
Table lookup and mask, score = 256 * (5*7+1*5) = 10240

Uses table lookup with a mask to pick out only the result we want.  Uses the fact that j|-j is either negative (when i!=x) or zero (when i==x).  Shifting makes an all-one or all-zero mask which is used to select out only the entry we want.

static const unsigned char t[256] = {
  0x63,0x7C,0x77,0x7B,0xF2,0x6B,0x6F,0xC5,0x30,0x01,0x67,0x2B,0xFE,0xD7,0xAB,0x76,
  0xCA,0x82,0xC9,0x7D,0xFA,0x59,0x47,0xF0,0xAD,0xD4,0xA2,0xAF,0x9C,0xA4,0x72,0xC0,
  0xB7,0xFD,0x93,0x26,0x36,0x3F,0xF7,0xCC,0x34,0xA5,0xE5,0xF1,0x71,0xD8,0x31,0x15,
  0x04,0xC7,0x23,0xC3,0x18,0x96,0x05,0x9A,0x07,0x12,0x80,0xE2,0xEB,0x27,0xB2,0x75,
  0x09,0x83,0x2C,0x1A,0x1B,0x6E,0x5A,0xA0,0x52,0x3B,0xD6,0xB3,0x29,0xE3,0x2F,0x84,
  0x53,0xD1,0x00,0xED,0x20,0xFC,0xB1,0x5B,0x6A,0xCB,0xBE,0x39,0x4A,0x4C,0x58,0xCF,
  0xD0,0xEF,0xAA,0xFB,0x43,0x4D,0x33,0x85,0x45,0xF9,0x02,0x7F,0x50,0x3C,0x9F,0xA8,
  0x51,0xA3,0x40,0x8F,0x92,0x9D,0x38,0xF5,0xBC,0xB6,0xDA,0x21,0x10,0xFF,0xF3,0xD2,
  0xCD,0x0C,0x13,0xEC,0x5F,0x97,0x44,0x17,0xC4,0xA7,0x7E,0x3D,0x64,0x5D,0x19,0x73,
  0x60,0x81,0x4F,0xDC,0x22,0x2A,0x90,0x88,0x46,0xEE,0xB8,0x14,0xDE,0x5E,0x0B,0xDB,
  0xE0,0x32,0x3A,0x0A,0x49,0x06,0x24,0x5C,0xC2,0xD3,0xAC,0x62,0x91,0x95,0xE4,0x79,
  0xE7,0xC8,0x37,0x6D,0x8D,0xD5,0x4E,0xA9,0x6C,0x56,0xF4,0xEA,0x65,0x7A,0xAE,0x08,
  0xBA,0x78,0x25,0x2E,0x1C,0xA6,0xB4,0xC6,0xE8,0xDD,0x74,0x1F,0x4B,0xBD,0x8B,0x8A,
  0x70,0x3E,0xB5,0x66,0x48,0x03,0xF6,0x0E,0x61,0x35,0x57,0xB9,0x86,0xC1,0x1D,0x9E,
  0xE1,0xF8,0x98,0x11,0x69,0xD9,0x8E,0x94,0x9B,0x1E,0x87,0xE9,0xCE,0x55,0x28,0xDF,
  0x8C,0xA1,0x89,0x0D,0xBF,0xE6,0x42,0x68,0x41,0x99,0x2D,0x0F,0xB0,0x54,0xBB,0x16};

unsigned char SubBytes(unsigned char x) {
  unsigned char r = 255;
  for (int i = 0; i < 256; i++) {
    int j = i - x;
    r &= t[i] | ((j | -j) >> 31);
  }
  return r;
}


Body:
Javascript (ES6), <s>57</s> <s>54</s> 53 bytes

l=>l.sort((a,b)=>(s=a=>1/a+`${a}`.length)(a)-s(b))[0]

For the record, my previous version was more math-oriented but 1 byte bigger:

l=>l.sort((a,b)=>(s=a=>1/a-~Math.log10(a))(a)-s(b))[0]

Test cases

let f =
l=>l.sort((a,b)=>(s=a=>1/a+`${a}`.length)(a)-s(b))[0]

console.log(f([1]));                              //  -> 1
console.log(f([9]));                              //  -> 9
console.log(f([1729]));                           //  -> 1729
console.log(f([1, 1]));                           //  -> 1
console.log(f([34, 3]));                          //  -> 3
console.log(f([38, 39]));                         //  -> 39
console.log(f([409, 12, 13]));                    //  -> 13
console.log(f([11, 11, 11, 1]));                  //  -> 1
console.log(f([11, 11, 11, 11]));                 //  -> 11
console.log(f([78, 99, 620, 1]));                 //  -> 1
console.log(f([78, 99, 620, 10]));                //  -> 99
console.log(f([78, 99, 620, 100]));               //  -> 99
console.log(f([1, 5, 9, 12, 63, 102]));           //  -> 9
console.log(f([3451, 29820, 2983, 1223, 1337]));  //  -> 3451
console.log(f([738, 2383, 281, 938, 212, 1010])); //  -> 938


问:
Determine win in Tictactoe
Let's play some code golf!

Given a tic-tac-toe board state (Example:)

```<code>|x|x|o|
|x|o|x|
|o|o|x|
</code>```

Determine whether a game is a win a lose or cat. Your code should output any of these options given a state. The above game should output lose

Just to be clear: a win is defined as any 3 xs in a row (diagonal, horizontal, vertical). a lose is 3 os in a row, while a cat game in none in a row.

To make things interesting, you get to determine your input structure for the state- which you must then explain. For instance xxoxoxoox is a valid state as seen above where each of the characters is read from left to right, top to bottom. [['x','x','o'],['x','o','x'],['o','o','x']] is the game in multidimensional array read in a similar way. While 0x1a9 which is hex for 110101001 might work as a suitable compression where 1 can be manipulated for xs and 0 can be manipulated for o.

But those are just some ideas, I'm sure you might have many of your own.

Ground rules:

Your program must be able to accept any viable state.

The form of input must be able to represent any state.

The input cannot be redundant, meaning each cell must only appear in one location.

"The win state must be determined from the board"

Assume a complete board

Win before lose for instance in the case 'xxxoooxxx'

Lowest character count wins

答:
Java 7, 260 bytes

```<code>String c(int[]s){int a[]=new int[8],x=0,y;for(;x<3;x++){for(y=0;y<3;a[x]+=s[x*3+y++]);for(y=0;y<3;a[x+3]+=s[y++%3]);}for(x=0;x<9;y=s[x],a[6]+=x%4<1?y:0;a[7]+=x%2<1&x>0&x++<8?y:0);x=0;for(int i:a)if(i>2)return"win";for(int i:a)if(i<1)return"loose";return"cat";}
</code>```

Ungolfed & test cases:

Try it here.

```<code>class M{
  static String c(int[] s){
    int a[] = new int[8],
        x = 0,
        y;
    for(; x < 3; x++){
      for(y = 0; y < 3; a[x] += s[x * 3 + y++]);
      for (y = 0; y < 3; a[x + 3] += s[y++ % 3]);
    }
    for(x = 0; x < 9; y = s[x],
                      a[6] += x % 4 < 1
                               ? y
                               : 0,
                      a[7] += x % 2 < 1 & x > 0 & x++ < 8
                               ? y
                               : 0);
    x = 0;
    for(int i : a){
      if(i > 2){
        return "win";
      }
    }
    for(int i : a){
      if(i < 1){
        return "loose";
      }
    }
    return "cat";
  }

  public static void main(String[] a){
    /*  xxo
        xox
        oox  */
    System.out.println(c(new int[]{ 1, 1, 0, 1, 0, 1, 0, 0, 1 }));
    /*  xxx
        ooo
        xxx  */
    System.out.println(c(new int[]{ 1, 1, 1, 0, 0, 0, 1, 1, 1 }));
    /*  xxo
        oox
        xox  */
    System.out.println(c(new int[]{ 1, 1, 0, 0, 0, 1, 1, 0, 1 }));
  }
}
</code>```

Output:

```<code>loose
win
cat
</code>```

Title: Determine win in Tictactoe

Body:
Java 7, 260 bytes

String c(int[]s){int a[]=new int[8],x=0,y;for(;x<3;x++){for(y=0;y<3;a[x]+=s[x*3+y++]);for(y=0;y<3;a[x+3]+=s[y++%3]);}for(x=0;x<9;y=s[x],a[6]+=x%4<1?y:0;a[7]+=x%2<1&x>0&x++<8?y:0);x=0;for(int i:a)if(i>2)return"win";for(int i:a)if(i<1)return"loose";return"cat";}

Ungolfed & test cases:

Try it here.

class M{
  static String c(int[] s){
    int a[] = new int[8],
        x = 0,
        y;
    for(; x < 3; x++){
      for(y = 0; y < 3; a[x] += s[x * 3 + y++]);
      for (y = 0; y < 3; a[x + 3] += s[y++ % 3]);
    }
    for(x = 0; x < 9; y = s[x],
                      a[6] += x % 4 < 1
                               ? y
                               : 0,
                      a[7] += x % 2 < 1 & x > 0 & x++ < 8
                               ? y
                               : 0);
    x = 0;
    for(int i : a){
      if(i > 2){
        return "win";
      }
    }
    for(int i : a){
      if(i < 1){
        return "loose";
      }
    }
    return "cat";
  }

  public static void main(String[] a){
    /*  xxo
        xox
        oox  */
    System.out.println(c(new int[]{ 1, 1, 0, 1, 0, 1, 0, 0, 1 }));
    /*  xxx
        ooo
        xxx  */
    System.out.println(c(new int[]{ 1, 1, 1, 0, 0, 0, 1, 1, 1 }));
    /*  xxo
        oox
        xox  */
    System.out.println(c(new int[]{ 1, 1, 0, 0, 0, 1, 1, 0, 1 }));
  }
}

Output:

loose
win
cat


Title: Invert a boolean array

Body:
 Common Lisp, 7

bit-not

Negate bits on a bit array.

Example

(bit-not #*00101010010100101001010010101)
=> #*11010101101011010110101101010


答:
Java 7, <s>112</s> 104 bytes

```<code>int c(int[]a){int i=a[0],j;for(int b:a)i=(j=(i+"").length()-(b+"").length())>0?b:b>i&j==0?b:i;return i;}
</code>```

Different approach to save multiple bytes thanks to @Barteks2x.

Ungolfed & test cases:

Try it here.

```<code>class M{
  static int c(int[] a){
    int i = a[0],
        j;
    for(int b : a){
      i = (j = (i+"").length() - (b+"").length()) > 0
           ? b
           : b > i & j == 0
              ? b
              : i;
    }
    return i;
  }

  public static void main(String[] a){
    System.out.println(c(new int[]{ 1 }));
    System.out.println(c(new int[]{ 9 }));
    System.out.println(c(new int[]{ 1729 }));
    System.out.println(c(new int[]{ 1, 1 }));
    System.out.println(c(new int[]{ 34, 3 }));
    System.out.println(c(new int[]{ 409, 12, 13 }));
    System.out.println(c(new int[]{ 11, 11, 11, 1 }));
    System.out.println(c(new int[]{ 11, 11, 11, 11 }));
    System.out.println(c(new int[]{ 78, 99, 620, 1 }));
    System.out.println(c(new int[]{ 78, 99, 620, 100 }));
    System.out.println(c(new int[]{ 1, 5, 9, 12, 63, 102 }));
    System.out.println(c(new int[]{ 3451, 29820, 2983, 1223, 1337 }));
    System.out.println(c(new int[]{ 738, 2383, 281, 938, 212, 1010 }));
  }
}
</code>```

Output:

```<code>1
9
1729
1
3
13
1
11
1
99
9
3451
938
</code>```

Body:
Given a nonempty list of positive decimal integers, output the largest number from the set of numbers with the fewest digits.

The input list will not be in any particular order and may contain repeated values.

Examples:

```<code>[1] -> 1
[9] -> 9
[1729] -> 1729
[1, 1] -> 1
[34, 3] -> 3
[38, 39] -> 39
[409, 12, 13] -> 13
[11, 11, 11, 1] -> 1
[11, 11, 11, 11] -> 11
[78, 99, 620, 1] -> 1
[78, 99, 620, 10] -> 99
[78, 99, 620, 100] -> 99
[1, 5, 9, 12, 63, 102] -> 9
[3451, 29820, 2983, 1223, 1337] -> 3451
[738, 2383, 281, 938, 212, 1010] -> 938
</code>```

The shortest code in bytes wins.

Body:
Java 7, <s>112</s> 104 bytes

int c(int[]a){int i=a[0],j;for(int b:a)i=(j=(i+"").length()-(b+"").length())>0?b:b>i&j==0?b:i;return i;}

Different approach to save multiple bytes thanks to @Barteks2x.

Ungolfed & test cases:

Try it here.

class M{
  static int c(int[] a){
    int i = a[0],
        j;
    for(int b : a){
      i = (j = (i+"").length() - (b+"").length()) > 0
           ? b
           : b > i & j == 0
              ? b
              : i;
    }
    return i;
  }

  public static void main(String[] a){
    System.out.println(c(new int[]{ 1 }));
    System.out.println(c(new int[]{ 9 }));
    System.out.println(c(new int[]{ 1729 }));
    System.out.println(c(new int[]{ 1, 1 }));
    System.out.println(c(new int[]{ 34, 3 }));
    System.out.println(c(new int[]{ 409, 12, 13 }));
    System.out.println(c(new int[]{ 11, 11, 11, 1 }));
    System.out.println(c(new int[]{ 11, 11, 11, 11 }));
    System.out.println(c(new int[]{ 78, 99, 620, 1 }));
    System.out.println(c(new int[]{ 78, 99, 620, 100 }));
    System.out.println(c(new int[]{ 1, 5, 9, 12, 63, 102 }));
    System.out.println(c(new int[]{ 3451, 29820, 2983, 1223, 1337 }));
    System.out.println(c(new int[]{ 738, 2383, 281, 938, 212, 1010 }));
  }
}

Output:

1
9
1729
1
3
13
1
11
1
99
9
3451
938


答:
Mathematica, 61 bytes

Yeah, total thread necro. Just wanted to see if I could do it at all! (Mathematica command names tend to be pretty verbose and thus vowel-heavy....)

Each of the two commands

```<code>Alphabet[]
</code>```

and

```<code>Union@@(StringSplit[#,""]&/@WordList[][[443;;692]])
</code>```

outputs a list of the 26 lowercase letters in order. StringSplit[#,""]& splits its input string at every occurrence of "", that is, between every character (hence accomplishes the same as the command Characters@#, but without that nasty "a" or "e"). This is applied to a set of 250 words, namely the 443rd to 692th words of the built-in word list. (The 443rd word, "adequateness", is needed for its "q", while the 692nd word, "aftershock", is needed for its "k". None of the first 427 words contains an "x", and the 428th word, "add-on", has an unfortunate hyphen; so we had to start over to find a contiguous block that works.) Finally, Union removes repetitions and sorts the list to boot.

Title: Print the alphabet without using each vowel

Body:
Inspiration: in 1939, a man named Ernest Vincent Wright wrote a novel called Gadsby without using the letter 'e'.

Your task is to write a set of (up to 5) programs in any language (which has a text-based syntax*) to output all 26 letters of the alphabet in order.  However for each vowel aeiou, at least one of the programs must not include any occurrence of the vowel.

So there must be

a program that does not use 'a' or 'A' anywhere in the syntax of the program.

a program that does not use 'e' or 'E' anywhere in the syntax of the program.

a program that does not use 'i'  or 'I' anywhere in the syntax of the program.

a program that does not use 'o' or 'O' anywhere in the syntax of the program.

a program that does not use 'u' or 'U' anywhere in the syntax of the program.

All of them must output abcdefghijklmnopqrstuvwxyz.

The winner shall be the solution where the length of all programs is the shortest.

* since the constraint wouldn't be much of a challenge in Piet or Whitespace

Body:
Mathematica, 61 bytes

Yeah, total thread necro. Just wanted to see if I could do it at all! (Mathematica command names tend to be pretty verbose and thus vowel-heavy....)

Each of the two commands

Alphabet[]

and

Union@@(StringSplit[#,""]&/@WordList[][[443;;692]])

outputs a list of the 26 lowercase letters in order. StringSplit[#,""]& splits its input string at every occurrence of "", that is, between every character (hence accomplishes the same as the command Characters@#, but without that nasty "a" or "e"). This is applied to a set of 250 words, namely the 443rd to 692th words of the built-in word list. (The 443rd word, "adequateness", is needed for its "q", while the 692nd word, "aftershock", is needed for its "k". None of the first 427 words contains an "x", and the 428th word, "add-on", has an unfortunate hyphen; so we had to start over to find a contiguous block that works.) Finally, Union removes repetitions and sorts the list to boot.


Body:
JavaScript (ES6), 51

l=>l.sort((a,b)=>(a+l).length-(b+l).length||b-a)[0]

Test

f=l=>l.sort((a,b)=>(a+l).length-(b+l).length||b-a)[0]

;[
 [[1], 1]
,[[9], 9]
,[[1729], 1729]
,[[1, 1], 1]
,[[34, 3], 3]
,[[38, 39], 39]
,[[409, 12, 13], 13]
,[[11, 11, 11, 1], 1]
,[[11, 11, 11, 11], 11]
,[[78, 99, 620, 1], 1]
,[[78, 99, 620, 10], 99]
,[[78, 99, 620, 100], 99]
,[[1, 5, 9, 12, 63, 102], 9]
,[[3451, 29820, 2983, 1223, 1337], 3451]
,[[738, 2383, 281, 938, 212, 1010], 938]
].forEach(([l,x])=>{
  var r=f(l)
  console.log(r==x?'OK':'KO',l+' -> '+r)
})