答:
Python 2, 243 bytes

r=range(input())
a=[1j**int((4*i+1)**.5)for i in r]
b=[map(int,(-sum(a[:i]).real,sum(a[:i]).imag))for i in r]
c,d=zip(*b)
for i in range(min(c),max(c)+1):print''.join([i,j]in b and chr(b.index([i,j])%26+65)or' 'for j in range(min(d),max(d)+1))
```

Ideone it!

Title: Roll the Alphabet into a Spiral

Body:
Write a program or function that, when given n, will print a spiral n characters long made up of the Latin alphabet ABCDEFGHIJKLMNOPQRSTUVWXYZ repeated as needed. This spiral should run through the alphabet only forwards.

Related to Alphabet Spiral, though the spiral runs through the alphabet forwards and backwards, and the spiral is constant.

Test cases

```<code>4   AB
    DC

40   UVWXYZ
     TGHIJA
    NSFABKB
    MREDCLC
    LQPONMD
    KJIHGFE

0

10  GHIJ
    FAB
    EDC

1000    UVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ
        TGHIJKLMNOPQRSTUVWXYZABCDEFGHIJA
        SFABCDEFGHIJKLMNOPQRSTUVWXYZABKB
        REZCDEFGHIJKLMNOPQRSTUVWXYZABCLC
        QDYBMNOPQRSTUVWXYZABCDEFGHIJCDMD
        PCXALEFGHIJKLMNOPQRSTUVWXYZKDENE
        OBWZKDEFGHIJKLMNOPQRSTUVWXALEFOF
        NAVYJCDMNOPQRSTUVWXYZABCDYBMFGPG
        MZUXIBCLCDEFGHIJKLMNOPQREZCNGHQH
        LYTWHABKBABCDEFGHIJKLMNSFADOHIRI
        KXSVGZAJAZGHIJKLMNOPQROTGBEPIJSJ
        JWRUFYZIZYFUVWXYZABCDSPUHCFQJKTK
        IVQTEXYHYXETQRSTUVWXETQVIDGRKLUL
        HUPSDWXGXWDSPUVWXYZYFURWJEHSLMVM
        GTORCVWFWVCROTGHIJAZGVSXKFITMNWN
        FSNQBUVEVUBQNSFABKBAHWTYLGJUNOXO
        ERMPATUDUTAPMREDCLCBIXUZMHKVOPYP
        DQLOZSTCTSZOLQPONMDCJYVANILWPQZQ
        CPKNYRSBSRYNKJIHGFEDKZWBOJMXQRAR
        BOJMXQRARQXMLKJIHGFELAXCPKNYRSBS
        ANILWPQZQPWVUTSRQPONMBYDQLOZSTCT
        ZMHKVOPYPONMLKJIHGFEDCZERMPATUDU
        YLGJUNOXONMLKJIHGFEDCBAFSNQBUVEV
        XKFITMNWVUTSRQPONMLKJIHGTORCVWFW
        WJEHSLMLKJIHGFEDCBAZYXWVUPSDWXGX
        VIDGRKJIHGFEDCBAZYXWVUTSRQTEXYHY
        UHCFQPONMLKJIHGFEDCBAZYXWVUFYZIZ
        TGBEDCBAZYXWVUTSRQPONMLKJIHGZAJA
        SFAZYXWVUTSRQPONMLKJIHGFEDCBABKB
        REDCBAZYXWVUTSRQPONMLKJIHGFEDCLC
        QPONMLKJIHGFEDCBAZYXWVUTSRQPONMD
                                LKJIHGFE
</code>```

Rules

Your input will be a non-negative integer 0 <= n <= 1000, but your code should theoretically handle any non-negative integer.

Your output format may be in any sane format, with delimiters if necessary.

Rotations and reflections are equivalent.

Your alphabet may be uppercase or lowercase.

The empty spaces in your spiral may be filled in with whatever non-alphabetic nulls you see fit.

The spiral itself may be in any shape you see fit. Rectangular spirals work best with ASCII solutions, but graphical solutions may be shorter with circular spirals.

Leading and trailing spaces and newlines are allowed.

This is code golf. The shortest answer in bytes (or equivalent) wins.

As always, if anything is unclear or incorrect, please let me know in the comments. Good luck and good golfing!

Body:
Python 2, 243 bytes

r=range(input())
a=[1j**int((4*i+1)**.5)for i in r]
b=[map(int,(-sum(a[:i]).real,sum(a[:i]).imag))for i in r]
c,d=zip(*b)
for i in range(min(c),max(c)+1):print''.join([i,j]in b and chr(b.index([i,j])%26+65)or' 'for j in range(min(d),max(d)+1))

Ideone it!


问:
Shortest code to produce infinite output
Write the shortest code you can that produces an infinite output.

That's all. You code will only be disqualified if it stops producing output at some point. As always in code golf, the shortest code wins.

Here's a list of answers that I think are really clever, so they can get credit:

The comma is both code and data

Infinite errors (that counts)

Infinite warnings (that also counts)

What's Marbelous?

Leaderboard

var QUESTION_ID=13152,OVERRIDE_USER=8611;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"https://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="
"+e.body.replace(OVERRIDE_REG,"")+"
")});var a=r.match(SCORE_REG);a&&e.push({user:getAuthorName(s),size:+a[2],language:a[1],link:s.share_link})}),e.sort(function(e,s){var r=e.size,a=s.size;return r-a});var s={},r=1,a=null,n=1;e.forEach(function(e){e.size!=a&&(n=r),a=e.size,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.size).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.language;/s.lang?1:e.lang<s.lang?-1:0});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.lang).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.size).replace("{{LINK}}",o.link),i=jQuery(i),jQuery("#languages").append(i)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/,OVERRIDE_REG=/^Override\s*header:\s*/i;```
<pre class="snippet-code-css lang-css prettyprint-override"><code>body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px}</code>```

 <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b">

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

答:
Hexagony, 1 byte

This answer is non-competing, as Hexagony is newer than this challenge.

```<code>!
</code>```

Try it online!

Prints an infinite amount of 0s by printing the value of the initial memory edge (which happens to be 0) over and over. The ! is executed in a loop because the source code is toroidal.

ContentLicense: CC BY-SA 4.0

Body:
Hexagony, 1 byte

This answer is non-competing, as Hexagony is newer than this challenge.

!

Try it online!

Prints an infinite amount of 0s by printing the value of the initial memory edge (which happens to be 0) over and over. The ! is executed in a loop because the source code is toroidal.

ContentLicense: CC BY-SA 3.0


问:
Stock Exchange KoTH
The stock market is all about the speed of knowledge. Unlike previous challenges, the current stock price is not random: it is determined by those playing the game.  If you can identify an under-priced stock before anybody else, then you've written yourself a money-making program.

Price refers to the how much people are trading the stock for, while Value refers to the amount the stock is worth at the end of the game.

Each player starts with 1000 of each stock, and 0 relative net worth.  Each stock has a secret value, and your score at the end of the game is (stockValue for each ownedStock) + netWorth.  Your net worth can be negative.  In an N-player game, there are N stocks.

Steps:

The game follows the following steps:

You are given the secret value of a single stock.

You make an offer to sell X of Y stock for $Z

All players are given the offers, and each may choose one to accept

All players are informed of accepted offers

Go back to step 2

Each of the steps are given in detail below:

void secretValue(int stockType, int value):

The value you learn is not revealed to any other player.

The value is between 0 and 1000

Low values are more like to occur than high values (squared uniform distribution)

Offer makeOffer(List<Stock> currentStock)

You can return null to make no offer.

Offer acceptOffer(List<Offer> offers)

You can return null to accept none of them

If there are no available offers, this will not be called

If you accept, your net worth goes down by $Z (can go negative) and receive X of Y stock.  The opposite occurs with the seller.

If you accept an offer, the exchange will occur immediately, and the offer will be removed so additional players cannot accept it.

void acceptedOffers(List<Offer> offers)

Includes your accepted offers as well

Static variables or writing to files is not allowed.  (No persistent data from game to game)  Non-serious contenders are allowed.

Interfaces:

```<code>public final class Stock {
    public Stock(int stockType, int amount);
    public int getType();
    public int getAmount();
    public Stock minus(Stock other);
    public Stock plus(Stock other);
    public Stock minus(int amount);
    public Stock plus(int amount);
    public Stock setAmount(int amount);
}
public class Offer {
    public Offer(Stock offer, int payment);
    public Stock getOffer();
    public int getPayment();
}
</code>```

Non-Java submissions:

All calls consist of two lines: The first line is the function being called: SecretValue, MakeOffer, AcceptOffer, AcceptedOffers, SetRandom, and the second line containing the actual data.

Stocks are formatted with a : delimiter: stockType:stockAmount.

Offers are formatted with a @ delimiter: offer@price

Lists are formatted with a ; delimiter

SecretValue is formatted with a : delimiter: stockType:value

RandomSeed is used to make your submission deterministic.  If your submission uses randomness, please use the integer value passed as the seed!

All function calls need a response.  If the response is null or void, return an empty string.

Please include a command.txt that gives the command line arguments to run your submission

Scoring

Games consisting of 1000 turns will be run multiple times.  Players will be scored according to the ELO system, and paired with players of similar skill levels.  The player with the highest final ELO score wins!  (I've modified the system so that each game, ELO scores are updated for each player pairing)

The controller includes an autodownloader, so please start your submission with a header: Name, Language.  If your submission is not in Java, each code block should start with the name of the file.  (excluding the command file, which should be the first block in your post)

Running

There are 2 ways to run this project:

Download the source code, compile and run.  You can find the source on Github.  Run git clone --recursive https://github.com/nathanmerrill/StockExchange.git

Download the JAR executable.  Submissions should be placed in your current working directory in the /submissions folder.  You can download just the JAR, just the submissions, or both

Pass in run to run the project (default option), or pass in download to download all submissions so far from this question.

Scoreboard

```<code>1.  1308.1220497323848  Cheater
2.  1242.0333695640356  InsideTrader
3.  1158.3662658295411  UncleScrooge
4.  1113.8344000358493  BlackMarket
5.  1051.8370015258993  DartMonkey
6.  983.0545446731494   WarGamer
7.  939.457423938002    Spammer
8.  901.4372529538886   DumbBot
9.  859.0519326039137   ShutUpAndTakeMyMoney
10. 852.9448222849587   VincentKasuga
11. 718.2112067329083   Profiteer
</code>```

答:
Cheater, Java

Tries to sell nothing for money.

```<code>import java.util.List;
import java.util.Random;
import com.ppcg.stockexchange.*;

public class Cheater extends Player {
    private Random random = new Random();

    public Offer acceptOffer(List<Offer> offers) {
        return null;
    }

    public Offer makeOffer(List<Stock> currentStock){
        Stock stock = randomStock();
        int price = random.nextInt(100) + 1;
        return new Offer(stock.setAmount(0), price);
    }
}
</code>```

Title: Stock Exchange KoTH

Body:
Cheater, Java

Tries to sell nothing for money.

import java.util.List;
import java.util.Random;
import com.ppcg.stockexchange.*;

public class Cheater extends Player {
    private Random random = new Random();

    public Offer acceptOffer(List<Offer> offers) {
        return null;
    }

    public Offer makeOffer(List<Stock> currentStock){
        Stock stock = randomStock();
        int price = random.nextInt(100) + 1;
        return new Offer(stock.setAmount(0), price);
    }
}


答:
Brachylog, 2 bytes

```<code>ẉ⊥
</code>```

Try it online!

Not only does it print infinitely, this prints something much more interesting than most answers here: all integers.

Explanation

```<code>        Assign an integer value to the input ; since it is not constrained, it can take any
          value in (-∞, +∞), meaning there is an infinite number of choice points
        The way = is implemented makes it so that the order of choices it will try is:
          0, 1, -1, 2, -2, 3, -3, …

 ẉ      Write that integer to STDOUT, followed by a linebreak
  ⊥     False (i.e. go back and try the next integer choice point)
</code>```

Title: Shortest code to produce infinite output

Body:
Write the shortest code you can that produces an infinite output.

That's all. You code will only be disqualified if it stops producing output at some point. As always in code golf, the shortest code wins.

Here's a list of answers that I think are really clever, so they can get credit:

The comma is both code and data

Infinite errors (that counts)

Infinite warnings (that also counts)

What's Marbelous?

Leaderboard

var QUESTION_ID=13152,OVERRIDE_USER=8611;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"https://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="
"+e.body.replace(OVERRIDE_REG,"")+"
")});var a=r.match(SCORE_REG);a&&e.push({user:getAuthorName(s),size:+a[2],language:a[1],link:s.share_link})}),e.sort(function(e,s){var r=e.size,a=s.size;return r-a});var s={},r=1,a=null,n=1;e.forEach(function(e){e.size!=a&&(n=r),a=e.size,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.size).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.language;/s.lang?1:e.lang<s.lang?-1:0});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.lang).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.size).replace("{{LINK}}",o.link),i=jQuery(i),jQuery("#languages").append(i)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/,OVERRIDE_REG=/^Override\s*header:\s*/i;```
<pre class="snippet-code-css lang-css prettyprint-override"><code>body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px}</code>```

 <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b">

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

Body:
Brachylog, 2 bytes

ẉ⊥

Try it online!

Not only does it print infinitely, this prints something much more interesting than most answers here: all integers.

Explanation

        Assign an integer value to the input ; since it is not constrained, it can take any
          value in (-∞, +∞), meaning there is an infinite number of choice points
        The way = is implemented makes it so that the order of choices it will try is:
          0, 1, -1, 2, -2, 3, -3, …

 ẉ      Write that integer to STDOUT, followed by a linebreak
  ⊥     False (i.e. go back and try the next integer choice point)


问:
Sheffle tho vawols ureund!
Given an input string, output that string with all vowels a, e, i, o and u swapped at random between each other.

For example, in the string this is a test, there are 4 vowels: [i, i, a, e]. A valid shuffling of those vowels could be [a, i, e, i] therefore yielding the output thas is e tist.

About shuffling

All shuffles shall be equally likely if we consider equal vowels to be distinct. For the example above, those 24 shuffles are possible:

```
[i<sub>1</sub>, i<sub>2</sub>, a, e]    [i<sub>1</sub>, i<sub>2</sub>, e, a]    [i<sub>1</sub>, a, i<sub>2</sub>, e]    [i<sub>1</sub>, a, e, i<sub>2</sub>]
[i<sub>1</sub>, e, i<sub>2</sub>, a]    [i<sub>1</sub>, e, a, i<sub>2</sub>]    [i<sub>2</sub>, i<sub>1</sub>, a, e]    [i<sub>2</sub>, i<sub>1</sub>, e, a]
[i<sub>2</sub>, a, i<sub>1</sub>, e]    [i<sub>2</sub>, a, e, i<sub>1</sub>]    [i<sub>2</sub>, e, i<sub>1</sub>, a]    [i<sub>2</sub>, e, a, i<sub>1</sub>]
[a, i<sub>1</sub>, i<sub>2</sub>, e]    [a, i<sub>1</sub>, e, i<sub>2</sub>]    [a, i<sub>2</sub>, i<sub>1</sub>, e]    [a, i<sub>2</sub>, e, i<sub>1</sub>]
[a, e, i<sub>1</sub>, i<sub>2</sub>]    [a, e, i<sub>2</sub>, i<sub>1</sub>]    [e, i<sub>1</sub>, i<sub>2</sub>, a]    [e, i<sub>1</sub>, a, i<sub>2</sub>]
[e, i<sub>2</sub>, i<sub>1</sub>, a]    [e, i<sub>2</sub>, a, i<sub>1</sub>]    [e, a, i<sub>1</sub>, i<sub>2</sub>]    [e, a, i<sub>2</sub>, i<sub>1</sub>]
```

Each one should be equally as likely.

You may not try random shuffles of the entire string until finding one where all vowels are in the right place. In short, your code's running time shall be constant if the input is constant.

Inputs and outputs

You may assume that all letters in the input will be lowercase or uppercase. You may also support mixed casing, though this won't give you any bonus.

The input will always consist of printable ASCII characters. All characters that are in the input shall be in the output, only the vowels must be shuffled around and nothing else.

The input can be empty. There is no guarantee that the input will contain at least one vowel or at least one non-vowel.

You may take the input from STDIN, as a function parameter, or anything similar.

You may print the output to STDOUT, return it from a function, or anything similar.

Test cases

The first line is the given input. The second line is one of the possible outputs.

```<code><empty string>
<empty string>

a
a

cwm
cwm

the quick brown fox jumps over the lazy dog.
tho qeuck brewn fax jumps ovir the lozy dog.

abcdefghijklmnopqrstuvwxyz
abcdefghujklmnipqrstovwxyz

programming puzzles & code golf
pregromming pezzlos & coda gulf

fatalize
fitaleza

martin ender
mirten ander
</code>```

Scoring

This is code-golf, sa tho shirtist enswer en bytes wons.

答:
Javascript (ES6), <s>78</s> 76 bytes

```<code>s=>s.replace(r=/[aeiou]/g,_=>l.pop(),l=s.match(r).sort(_=>Math.random()-.5))
</code>```

Saved 2 bytes thanks to apsillers

Alternate version proposed by apsillers (76 bytes as well)

```<code>s=>s.replace(r=/[aeiou]/g,[].pop.bind(s.match(r).sort(_=>Math.random()-.5)))
</code>```

Test

let f =
s=>s.replace(r=/[aeiou]/g,_=>l.pop(),l=s.match(r).sort(_=>Math.random()-.5))

console.log(f("the quick brown fox jumps over the lazy dog."))```

Title: Sheffle tho vawols ureund!

Body:
Javascript (ES6), <s>78</s> 76 bytes

s=>s.replace(r=/[aeiou]/g,_=>l.pop(),l=s.match(r).sort(_=>Math.random()-.5))

Saved 2 bytes thanks to apsillers

Alternate version proposed by apsillers (76 bytes as well)

s=>s.replace(r=/[aeiou]/g,[].pop.bind(s.match(r).sort(_=>Math.random()-.5)))

Test

let f =
s=>s.replace(r=/[aeiou]/g,_=>l.pop(),l=s.match(r).sort(_=>Math.random()-.5))

console.log(f("the quick brown fox jumps over the lazy dog."))


问:
Quixels - Quantum Pixels

Introduction

A quixel is a quantum pixel. Similar to a classical pixel, it is represented with 3 integer values (Red, Green, Blue). However, quixels are in a super position of these 3 states instead of a combination. This super position only lasts until the quixel is observed at which point it collapses to one of three classical pixels; RGB(255,0,0), RGB(0,255,0) and RGB(0,0,255).

Specification

Representation

Each quixel is represented as an array of 3 integers between 0 and 255, r, g and b respectively.

Super Positions

Each quixel is in a super position between the Red, Blue and Green states represented by R, G and B respectively.

Observation

When each quixel is observed it collapses into one of the three states. The probability of each classical state is R = (r + 1) / (r + g + b +3), G = (g + 1) / (r + g + b + 3) and B = (b + 1) / (r + g + b + 3). This way each classical state always as a non-zero probability of showing up.

Input

The function or program should take a image of quixels. How it does this is flexible. A filename, using a multi-dimensional array, etc are all acceptable.

Output

The function or program should produce an image of classical pixels. The data structure for this produced image is also flexible. Note that all of the pixels should be one of these three: RGB(255,0,0), RGB(0,255,0) and RGB(0,0,255)

The output should not be deterministic; these are quantum pixels! The same input should result in different outputs.

If your language has no way of generating a random number, you can take random bytes as input

Scoring

This is code-golf so fewest bytes win.

Images

Mona Lisa by Leonardo da Vinci

Starry Night by Vincent van Gogh

Persistence of Memory by Salvador Dali

Teddy Roosevelt VS. Bigfoot by SharpWriter

答:
Jelly, <s>8</s> 7 bytes

```<code>Jx‘Xµ€€
</code>```

The input is a 3d list with dimensions h x w x 3. The output is a 2d list with dimensions h x w where 1 represents the rgb value (255, 0, 0), 2 is (0, 255, 0), and 3 is (0, 0, 255).

The sample input below is the top-left 4 x 4 region of the Mona Lisa image.

Try it online!

Explanation

```<code>Jx‘Xµ€€  Input: The 3d list of rgb pixels
    µ    Begin a monadic chain (Will operate on each pixel, input: [R, G, B])
J          Enumerate indices to get [1, 2, 3]
  ‘        Increment each to get [R+1, G+1, B+1]
 x         Make R+1 copies of 1, G+1 copies of 2, B+1 copies of 3
   X       Select a random value from that list of copies and return
     €€  Apply that monadic chain for each list inside each list
</code>```

Title: Quixels - Quantum Pixels

Body:
Jelly, <s>8</s> 7 bytes

Jx‘Xµ€€

The input is a 3d list with dimensions h x w x 3. The output is a 2d list with dimensions h x w where 1 represents the rgb value (255, 0, 0), 2 is (0, 255, 0), and 3 is (0, 0, 255).

The sample input below is the top-left 4 x 4 region of the Mona Lisa image.

Try it online!

Explanation

Jx‘Xµ€€  Input: The 3d list of rgb pixels
    µ    Begin a monadic chain (Will operate on each pixel, input: [R, G, B])
J          Enumerate indices to get [1, 2, 3]
  ‘        Increment each to get [R+1, G+1, B+1]
 x         Make R+1 copies of 1, G+1 copies of 2, B+1 copies of 3
   X       Select a random value from that list of copies and return
     €€  Apply that monadic chain for each list inside each list


问:
The Squiggly Sequence

All credits to Adnan for coming up with this challenge.

My last challenge, before I go on break.

Task

Given positive integer n, if n is odd, repeat / that many times; if n is even, repeat \ that many times.

(Seriously, the testcases would be much clearer than this description, so just look at the testcases.)

Specs

Any reasonable input/output format.

Standard loopholes apply.

Testcases

```<code>n output
1 /
2 \\
3 ///
4 \\\\
5 /////
6 \\\\\\
</code>```

答:
CJam, 9 bytes

```<code>ri_"\/"=*
</code>```

Try it online!

Explanation

```<code>ri     e# Read input and convert to integer N.
_      e# Duplicate N.
"\/"=  e# Use N as cyclic index into "\/", giving '\ for even and '/ for odd inputs.
*      e# Repeat N times.
</code>```

Title: The Squiggly Sequence

Body:
CJam, 9 bytes

ri_"\/"=*

Try it online!

Explanation

ri     e# Read input and convert to integer N.
_      e# Duplicate N.
"\/"=  e# Use N as cyclic index into "\/", giving '\ for even and '/ for odd inputs.
*      e# Repeat N times.


问:
Hate/love conundrum

Challenge description

In this challenge, we only consider love and hate as feelings. If we want to utter a feeling expression of order N, we alternate between these two (starting with hate):

```<code>order | expression

1       I hate it.
2       I hate that I love it.
3       I hate that I love that I hate it.
4       I hate that I love that I hate that I love it.
</code>```

The pattern follows for every positive integer N. Given N, output the correspoinding feeling expression of order N.

Notes

Full stop (.) at the end of the expression is mandatory,

Trailing and leading whitespaces (including newlines) are permitted,

Output for a non-positive or non-integer N is undefined,

This is a code-golf challenge, so make your code as short as possible!

答:
Python, 54 bytes

lambda n:("I hate that I love that "*n)[:12*n-5]+"it."
```

Python 2: Ideone it!

Python 3: Ideone it!

Title: Hate/love conundrum

Body:
Python, 54 bytes

lambda n:("I hate that I love that "*n)[:12*n-5]+"it."

Python 2: Ideone it!

Python 3: Ideone it!


答:
Java 8, 56 bytes

```<code>(i,j)->{for(j=i;j-->0;)System.out.print(i%2<1?92:'/');};
</code>```

I'd like to thank @Kevin Cruijssen in advanced for golfing my answer further.

Ungolfed Test Program

```<code>public static void main(String[] args) {
    BiConsumer<Integer, Integer> consumer = (i, j) -> {
        for (j = i; j-- > 0;) {
            System.out.print(i % 2 < 1 ? 92 : '/');
        }
    };

    consumer.accept(5, 0);
    consumer.accept(1, 0);
    consumer.accept(8, 0);
}
</code>```

Title: The Squiggly Sequence

Body:
All credits to Adnan for coming up with this challenge.

My last challenge, before I go on break.

Task

Given positive integer n, if n is odd, repeat / that many times; if n is even, repeat \ that many times.

(Seriously, the testcases would be much clearer than this description, so just look at the testcases.)

Specs

Any reasonable input/output format.

Standard loopholes apply.

Testcases

```<code>n output
1 /
2 \\
3 ///
4 \\\\
5 /////
6 \\\\\\
</code>```

Body:
Java 8, 56 bytes

(i,j)->{for(j=i;j-->0;)System.out.print(i%2<1?92:'/');};

I'd like to thank @Kevin Cruijssen in advanced for golfing my answer further.

Ungolfed Test Program

public static void main(String[] args) {
    BiConsumer<Integer, Integer> consumer = (i, j) -> {
        for (j = i; j-- > 0;) {
            System.out.print(i % 2 < 1 ? 92 : '/');
        }
    };

    consumer.accept(5, 0);
    consumer.accept(1, 0);
    consumer.accept(8, 0);
}


问:
How many switches are ON
A class has N student and the class room has N switches (all turned OFF and numbered 1 to N). Each student has an enrollment number assigned from 1 to N. Each student serially (by number) toggles the switches that has a number which is divisible by his/her enrollment number.

Example: Student 1 will turn all the switches ON. Student 2 will turn all even switches OFF. Student N just toggles the Nth switch.

Write a function that takes N as input as returns number of ON switches.
sample I/O

```<code>Input: 10
Output:3
</code>```

No upper bound for N is given, but greater the scope, better the code. Shortest and innovative function wins

答:
dc - 5 chars

```<code>[v]sf
</code>```

Square root in dc is v. Using stdin/stdout takes 3 chars (?vp)

ContentLicense: CC BY-SA 2.5

Title: How many switches are ON

Body:
dc - 5 chars

[v]sf

Square root in dc is v. Using stdin/stdout takes 3 chars (?vp)


问:
"Defragmenting" a list
A fragmented file is a file which is seperated into several parts on a harddrive, because it can't fit into a certain space.

On all harddrives, there are files called unmovable files, which are unmovable. To simulate real data on a harddrive, the input will also have unmovable files.

You are given several sequences of consecutive numbers, all scrambled into one list. The goal is to order each of these sequences so that they are placed in as little space as possible. The list can be as big as you need it to be. If there is no space for a sequence, then put a - instead.

To mark the unmovable files, another list, with the same length as the data, will be given after you recieve the data. It will contain either a 0 or a 1. Every 1 within that list means that the corresponding item in the data is unmovable.

Shortest code wins.

Test Cases

The output does not have to be exactly like this, but the length needs to be the same, and all of the sequences need to be ordered.

```<code>[ 0,  0,  1,  1,  1,  1,  0,  0,  0,  0,  0]
[25, 30, 11, 12, 13, 14, 68, 69, 31, 26, 32]
Output: [25, 26, 11, 12, 13, 14, 68, 69, 30, 31, 32]
(output length: 11)

[0, 0, 0,  0, 0,  1,  1,  1, 0, 0,  0,  0,  0,  0,  0, 0]
[2, 3, 5, 14, 8, 10, 11, 12, 4, 6, 28, 30, 29, 15, 16, 7]
Output: [14, 15, 16, -, -, 10, 11, 12, 2, 3, 4, 5, 6, 7, 8, 28, 29, 30]
(output length: 18)
</code>```

答:
I decided to tackle this solution in Scala, taking advantage of both functional and imperative features of the hybrid language. Here is the code for my solution.

```<code>def orderedSequences(filePieces: List[(Int,Int)]): List[List[(Int,Int)]] = {
  def orderedSequencesR(filePieces: List[(Int,Int)], currentSequence: List[(Int,Int)], sequences: List[List[(Int,Int)]]): List[List[(Int,Int)]] = {
    if(filePieces == Nil) sequences :+ currentSequence
    else if(currentSequence == List.empty) orderedSequencesR(filePieces.tail, List(filePieces.head), sequences)
    else if(filePieces.head._2 == currentSequence.last._2 + 1) orderedSequencesR(filePieces.tail, currentSequence :+ filePieces.head, sequences)
    else orderedSequencesR(filePieces, List.empty, sequences :+ currentSequence)
  }
  orderedSequencesR(filePieces, List.empty, List.empty)
}

def defragment(sequences: List[List[(Int,Int)]], filePieces: List[(Int,Int)]): List[Any] = {
  val largestSequenceLength = sequences.flatten.length
  var solution = scala.collection.mutable.ListBuffer[(Int,Int)]()

  filePieces foreach {filePiece => if(filePiece._1 == 1) solution += filePiece  else solution += ((-1,0))}

  solution ++ Iterator.fill(largestSequenceLength)((-1,0))

  sequences foreach {
      sequence =>
      var sequenceIsInserted = false
      var currentPosition = 0
      while(!sequenceIsInserted) {
        if(solution.slice(currentPosition,currentPosition + sequence.length).forall((s: (Int,Int)) => s._1 == -1)){
          solution = solution.slice(0,currentPosition) ++ sequence ++ solution.slice(currentPosition + sequence.length, solution.length)
          sequenceIsInserted = true
        }
        currentPosition += 1
      }
  }

  solution.map(_._2).toList
}

def getDefragmentedFiles(isUnmovable: List[Int], files: List[Int]) = {
    val filePieces = isUnmovable zip files
    val sequences = orderedSequences(filePieces.filter(os => os._1 == 0).sortBy(t => t._2))
    val bestSolution = defragment(sequences.permutations.toList.sortBy {b => defragment(b, filePieces).length}.head, filePieces)
    println(bestSolution map { case 0 => '-'; case x => x })
}

val isUnmovable = List(0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0)
val files = List(2,3,5,14,8,10,11,12,4,6,28,30,29,15,16,7)
getDefragmentedFiles(isUnmovable, files)
</code>```

I take the list of movable/unmovable positions along with the files and zip them up. I then get the movable files, sort them in order, and pass them into orderedSequences to get a list of file sequences.

Once I get the sequences, I get all the permutations of the sequences and I brute-force defrag them, taking the solution of the shortest length. This is pretty inefficient, but I can't think of a more efficient solution right now. The defrag method takes each sequence, in order, and iterates through the memory space until a valid spot to place the sequence is found.

After getting the best solution, I prettify it and print it out as a list.

Title: "Defragmenting" a list

Body:
I decided to tackle this solution in Scala, taking advantage of both functional and imperative features of the hybrid language. Here is the code for my solution.

def orderedSequences(filePieces: List[(Int,Int)]): List[List[(Int,Int)]] = {
  def orderedSequencesR(filePieces: List[(Int,Int)], currentSequence: List[(Int,Int)], sequences: List[List[(Int,Int)]]): List[List[(Int,Int)]] = {
    if(filePieces == Nil) sequences :+ currentSequence
    else if(currentSequence == List.empty) orderedSequencesR(filePieces.tail, List(filePieces.head), sequences)
    else if(filePieces.head._2 == currentSequence.last._2 + 1) orderedSequencesR(filePieces.tail, currentSequence :+ filePieces.head, sequences)
    else orderedSequencesR(filePieces, List.empty, sequences :+ currentSequence)
  }
  orderedSequencesR(filePieces, List.empty, List.empty)
}

def defragment(sequences: List[List[(Int,Int)]], filePieces: List[(Int,Int)]): List[Any] = {
  val largestSequenceLength = sequences.flatten.length
  var solution = scala.collection.mutable.ListBuffer[(Int,Int)]()

  filePieces foreach {filePiece => if(filePiece._1 == 1) solution += filePiece  else solution += ((-1,0))}

  solution ++ Iterator.fill(largestSequenceLength)((-1,0))

  sequences foreach {
      sequence =>
      var sequenceIsInserted = false
      var currentPosition = 0
      while(!sequenceIsInserted) {
        if(solution.slice(currentPosition,currentPosition + sequence.length).forall((s: (Int,Int)) => s._1 == -1)){
          solution = solution.slice(0,currentPosition) ++ sequence ++ solution.slice(currentPosition + sequence.length, solution.length)
          sequenceIsInserted = true
        }
        currentPosition += 1
      }
  }

  solution.map(_._2).toList
}

def getDefragmentedFiles(isUnmovable: List[Int], files: List[Int]) = {
    val filePieces = isUnmovable zip files
    val sequences = orderedSequences(filePieces.filter(os => os._1 == 0).sortBy(t => t._2))
    val bestSolution = defragment(sequences.permutations.toList.sortBy {b => defragment(b, filePieces).length}.head, filePieces)
    println(bestSolution map { case 0 => '-'; case x => x })
}

val isUnmovable = List(0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0)
val files = List(2,3,5,14,8,10,11,12,4,6,28,30,29,15,16,7)
getDefragmentedFiles(isUnmovable, files)

I take the list of movable/unmovable positions along with the files and zip them up. I then get the movable files, sort them in order, and pass them into orderedSequences to get a list of file sequences.

Once I get the sequences, I get all the permutations of the sequences and I brute-force defrag them, taking the solution of the shortest length. This is pretty inefficient, but I can't think of a more efficient solution right now. The defrag method takes each sequence, in order, and iterates through the memory space until a valid spot to place the sequence is found.

After getting the best solution, I prettify it and print it out as a list.


答:
Javascript (ES5), 99 94 bytes

```<code>function(c){for(d="",b=0;b<c;++b)d+=(b%2?"I love ":"I hate ")+(b==c-1?"it.":"that ");return d}
</code>```

Saved 5 bytes thanks to Leaky Nun.

OLD 99 byte solution:

```<code>function(c){for(d="",b=0;b<c;++b)d+=(0==b%2?"I hate":"I love")+" "+(b==c-1?"it.":"that ");return d}
</code>```

Another 98 byte solution:

```<code>function(d){for(c=[],b=0;b<d;++b)c.push(["love","hate"][b%2]);return"I "+c.join(" that I ")+" it"}
</code>```

My code before minification:

```<code>function a(n){
  var hate="I hate",love="I love",it="it ",that="that ",out="";
  for(var i=0;i<n;++i){out+=(i%2==0?hate:love)+" "+(i==n-1?it+".":that)}return out;
}
</code>```

Title: Hate/love conundrum

Body:
Challenge description

In this challenge, we only consider love and hate as feelings. If we want to utter a feeling expression of order N, we alternate between these two (starting with hate):

```<code>order | expression

1       I hate it.
2       I hate that I love it.
3       I hate that I love that I hate it.
4       I hate that I love that I hate that I love it.
</code>```

The pattern follows for every positive integer N. Given N, output the correspoinding feeling expression of order N.

Notes

Full stop (.) at the end of the expression is mandatory,

Trailing and leading whitespaces (including newlines) are permitted,

Output for a non-positive or non-integer N is undefined,

This is a code-golf challenge, so make your code as short as possible!

Body:
Javascript (ES5), 99 94 bytes

function(c){for(d="",b=0;b<c;++b)d+=(b%2?"I love ":"I hate ")+(b==c-1?"it.":"that ");return d}

Saved 5 bytes thanks to Leaky Nun.

OLD 99 byte solution:

function(c){for(d="",b=0;b<c;++b)d+=(0==b%2?"I hate":"I love")+" "+(b==c-1?"it.":"that ");return d}

Another 98 byte solution:

function(d){for(c=[],b=0;b<d;++b)c.push(["love","hate"][b%2]);return"I "+c.join(" that I ")+" it"}

My code before minification:

function a(n){
  var hate="I hate",love="I love",it="it ",that="that ",out="";
  for(var i=0;i<n;++i){out+=(i%2==0?hate:love)+" "+(i==n-1?it+".":that)}return out;
}


答:
CJam, 36 bytes

```<code>ri{"hatlov"3/='IS@"e that "}/2<"it."
</code>```

Try it online!

Explanation

```<code>ri            e# Read input and convert to integer N.
{             e# For each i from 0 to N-1...
  "hatlov"3/  e#   Push ["hat" "lov"].
  =           e#   Use i as a cyclic index into this array to alternate between
              e#   "hat" and "lov".
  'IS         e#   Push character 'I' and a space.
  @           e#   Pull "hat" or "lov" on top of it.
  "e that "   e#   Push "e that "
}/
2<            e#   Truncate the last "e that " to just "e ".
"it."         e#   Push "it."
</code>```

Title: Hate/love conundrum

Body:
CJam, 36 bytes

ri{"hatlov"3/='IS@"e that "}/2<"it."

Try it online!

Explanation

ri            e# Read input and convert to integer N.
{             e# For each i from 0 to N-1...
  "hatlov"3/  e#   Push ["hat" "lov"].
  =           e#   Use i as a cyclic index into this array to alternate between
              e#   "hat" and "lov".
  'IS         e#   Push character 'I' and a space.
  @           e#   Pull "hat" or "lov" on top of it.
  "e that "   e#   Push "e that "
}/
2<            e#   Truncate the last "e that " to just "e ".
"it."         e#   Push "it."


问:
"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

```

答:
Ru, 15 bytes

```<code>“Hello, World!”
</code>```

Body must be at least 30 characters; you entered 29.

Title: "Hello, World!"

Body:
Ru, 15 bytes

“Hello, World!”

Body must be at least 30 characters; you entered 29.


答:
Javascript (ES6), <s>75</s> <s>73</s> 70 bytes

```<code>n=>[...Array(n)].map((_,i)=>i&1?'I love':'I hate').join` that `+' it.'
</code>```

Saved 2 bytes thanks to Neil

Saved 3 bytes thanks to Whothehellisthat

Test

let f =
n=>[...Array(n)].map((_,i)=>i&1?'I love':'I hate').join` that `+' it.'

console.log(f(1))
console.log(f(2))
console.log(f(3))
console.log(f(4))```

Title: Hate/love conundrum

Body:
Javascript (ES6), <s>75</s> <s>73</s> 70 bytes

n=>[...Array(n)].map((_,i)=>i&1?'I love':'I hate').join` that `+' it.'

Saved 2 bytes thanks to Neil

Saved 3 bytes thanks to Whothehellisthat

Test

let f =
n=>[...Array(n)].map((_,i)=>i&1?'I love':'I hate').join` that `+' it.'

console.log(f(1))
console.log(f(2))
console.log(f(3))
console.log(f(4))


答:
05AB1E, <s>34</s> <s>32</s> 27 bytes

Saved 5 bytes thanks to Adnan.

```<code>“I«¢€Š I„Î€Š “×¹12*5-£…it.«
</code>```

Explanation

```<code>“I«¢€Š I„Î€Š “               # "I hate that I love that "
              ×              # repeat input nr of times
               ¹12*5-£       # take the first input*12-5 chars of string above
                      …it.«  # append "it."
                             # implicitly display
</code>```

Try it online!

Title: Hate/love conundrum

Body:
05AB1E, <s>34</s> <s>32</s> 27 bytes

Saved 5 bytes thanks to Adnan.

“I«¢€Š I„Î€Š “×¹12*5-£…it.«

Explanation

“I«¢€Š I„Î€Š “               # "I hate that I love that "
              ×              # repeat input nr of times
               ¹12*5-£       # take the first input*12-5 chars of string above
                      …it.«  # append "it."
                             # implicitly display

Try it online!


答:
C, <s>83</s> <s>76</s> <s>75</s> 74 bytes

Thanks to @Leaky Nun for saving 11 bytes and adding 4 bytes!

Thanks to @YSC for saving a byte!

i;f(n){for(i=0;n--;)printf("I %se %s",i++%2?"lov":"hat",n?"that ":"it.");}
```

Try it on Ideone

Title: Hate/love conundrum

Body:
C, <s>83</s> <s>76</s> <s>75</s> 74 bytes

Thanks to @Leaky Nun for saving 11 bytes and adding 4 bytes!

Thanks to @YSC for saving a byte!

i;f(n){for(i=0;n--;)printf("I %se %s",i++%2?"lov":"hat",n?"that ":"it.");}

Try it on Ideone


问:
As Easy as One-Two-Three
Write a program or function that takes in a positive integer. You can assume the input is valid and may take it as a string. If the number is any of

```<code>123
234
345
456
567
678
789
</code>```

then output a truthy value. Otherwise, output a falsy value. For example, the inputs

```<code>1
2
3
12
122
124
132
321
457
777
890
900
1011
1230
1234
</code>```

must all result in falsy output. (The input will not have leading zeroes so you needn't worry about things like 012.)

The shortest code in bytes wins.

Title: As Easy as One-Two-Three

Body:
C# 6 (36 bytes)

bool f(int x)=>x<790&0==(x+321)%111;


问:
Call a method without calling it
Inspired by a now deleted StackOverflow question. Can you come up with a way to get a particular method executed, without explicitly calling it? The more indirect it is, the better.

Here's what I mean, exactly (C used just for exemplification, all languages accepted):

// Call this.
void the_function(void)
{
    printf("Hi there!\n");
}

int main(int argc, char** argv)
{
    the_function(); // NO! Bad! This is a direct call.
    return 0;
}
```

Original question:

答:
GNU sed

There is a beautiful way to do this in sed. In fact, when writing programs you could easily fall into this trap without realizing. I already had a post on Tips for golfing in sed documenting this feature.

s/$/bar/
s/foo/&/
t foo_found()
b

:foo_found()
p
```

Run: sed -nf function_call.sed <<< ""

The foo_found() function is called when a search for foo is successful  anywhere in the pattern space. The first line of code writes bar into the pattern space, previously empty. However, it will also indirectly, and surprisingly, help in calling the function foo_found()!

When the first line is commented out, the function is not called, as it was meant in the first place.

Title: Call a method without calling it

Body:
GNU sed

There is a beautiful way to do this in sed. In fact, when writing programs you could easily fall into this trap without realizing. I already had a post on Tips for golfing in sed documenting this feature.

s/$/bar/
s/foo/&/
t foo_found()
b

:foo_found()
p

Run: sed -nf function_call.sed <<< ""

The foo_found() function is called when a search for foo is successful  anywhere in the pattern space. The first line of code writes bar into the pattern space, previously empty. However, it will also indirectly, and surprisingly, help in calling the function foo_found()!

When the first line is commented out, the function is not called, as it was meant in the first place.


答:
Perl, 38 bytes

Includes +1 for -p

Run with the sentence on STDIN

```<code>vawols.pl <<< "programming puzzles & code golf"
</code>```

vawols.pl:

```<code>#!/usr/bin/perl -p
@Q=/[aeiou]/g;s//splice@Q,rand@Q,1/eg
</code>```

Title: Sheffle tho vawols ureund!

Body:
Given an input string, output that string with all vowels a, e, i, o and u swapped at random between each other.

For example, in the string this is a test, there are 4 vowels: [i, i, a, e]. A valid shuffling of those vowels could be [a, i, e, i] therefore yielding the output thas is e tist.

About shuffling

All shuffles shall be equally likely if we consider equal vowels to be distinct. For the example above, those 24 shuffles are possible:

```
[i<sub>1</sub>, i<sub>2</sub>, a, e]    [i<sub>1</sub>, i<sub>2</sub>, e, a]    [i<sub>1</sub>, a, i<sub>2</sub>, e]    [i<sub>1</sub>, a, e, i<sub>2</sub>]
[i<sub>1</sub>, e, i<sub>2</sub>, a]    [i<sub>1</sub>, e, a, i<sub>2</sub>]    [i<sub>2</sub>, i<sub>1</sub>, a, e]    [i<sub>2</sub>, i<sub>1</sub>, e, a]
[i<sub>2</sub>, a, i<sub>1</sub>, e]    [i<sub>2</sub>, a, e, i<sub>1</sub>]    [i<sub>2</sub>, e, i<sub>1</sub>, a]    [i<sub>2</sub>, e, a, i<sub>1</sub>]
[a, i<sub>1</sub>, i<sub>2</sub>, e]    [a, i<sub>1</sub>, e, i<sub>2</sub>]    [a, i<sub>2</sub>, i<sub>1</sub>, e]    [a, i<sub>2</sub>, e, i<sub>1</sub>]
[a, e, i<sub>1</sub>, i<sub>2</sub>]    [a, e, i<sub>2</sub>, i<sub>1</sub>]    [e, i<sub>1</sub>, i<sub>2</sub>, a]    [e, i<sub>1</sub>, a, i<sub>2</sub>]
[e, i<sub>2</sub>, i<sub>1</sub>, a]    [e, i<sub>2</sub>, a, i<sub>1</sub>]    [e, a, i<sub>1</sub>, i<sub>2</sub>]    [e, a, i<sub>2</sub>, i<sub>1</sub>]
```

Each one should be equally as likely.

You may not try random shuffles of the entire string until finding one where all vowels are in the right place. In short, your code's running time shall be constant if the input is constant.

Inputs and outputs

You may assume that all letters in the input will be lowercase or uppercase. You may also support mixed casing, though this won't give you any bonus.

The input will always consist of printable ASCII characters. All characters that are in the input shall be in the output, only the vowels must be shuffled around and nothing else.

The input can be empty. There is no guarantee that the input will contain at least one vowel or at least one non-vowel.

You may take the input from STDIN, as a function parameter, or anything similar.

You may print the output to STDOUT, return it from a function, or anything similar.

Test cases

The first line is the given input. The second line is one of the possible outputs.

```<code><empty string>
<empty string>

a
a

cwm
cwm

the quick brown fox jumps over the lazy dog.
tho qeuck brewn fax jumps ovir the lozy dog.

abcdefghijklmnopqrstuvwxyz
abcdefghujklmnipqrstovwxyz

programming puzzles & code golf
pregromming pezzlos & coda gulf

fatalize
fitaleza

martin ender
mirten ander
</code>```

Scoring

This is code-golf, sa tho shirtist enswer en bytes wons.

Body:
Perl, 38 bytes

Includes +1 for -p

Run with the sentence on STDIN

vawols.pl <<< "programming puzzles & code golf"

vawols.pl:

#!/usr/bin/perl -p
@Q=/[aeiou]/g;s//splice@Q,rand@Q,1/eg


答:
Java 8, 91 bytes

```<code>i->{for(int j=0;j++<i;)System.out.printf("I %se %s",j%2>0?"hat":"lov",j<i?"that ":"it.");};
</code>```

Ungolfed Test Program

```<code>public static void main(String[] args) {
    Consumer<Integer> c = i -> {
        for (int j = 0; j++ < i;) {
            System.out.printf("I %se %s", j % 2 > 0 ? "hat" : "lov", j < i ? "that " : "it.");
        }
    };

    c.accept(1);
    c.accept(2);
    c.accept(3);
}
</code>```

Title: Hate/love conundrum

Body:
Java 8, 91 bytes

i->{for(int j=0;j++<i;)System.out.printf("I %se %s",j%2>0?"hat":"lov",j<i?"that ":"it.");};

Ungolfed Test Program

public static void main(String[] args) {
    Consumer<Integer> c = i -> {
        for (int j = 0; j++ < i;) {
            System.out.printf("I %se %s", j % 2 > 0 ? "hat" : "lov", j < i ? "that " : "it.");
        }
    };

    c.accept(1);
    c.accept(2);
    c.accept(3);
}


问:
10 PRINT CHR$(205.5+RND(1)); : GOTO 10 in PHP (or anything else, for that matter)
Just had a 'spirited' conversation with a co-worker about the succinctness of the following BASIC statement:

```<code>10 PRINT CHR$(205.5+RND(1)); : GOTO 10
</code>```

It's the title of this book, and will simply print a sequence of / and \ characters, alternating between the two randomly, resulting in a pattern similar to this:

(Image borrowed from http://www.flickr.com/photos/rndmcnlly/5058442151/sizes/o/in/photostream/)

Being of a PHP proclivity, we wondered what the most compact way of writing the same thing in PHP would be, and came up with this:

```<code>while(1) { echo chr(47 + 45 * rand(0,1)); }
</code>```

chr(47) is a / character, and chr(92) is a \. So the statement echo chr(47 + 45 * rand(0,1)); will randomly alternate between the two, ad nauseam.

In a language of your choosing, write the shortest program or function to output an infinite random sequence of \ and / characters, where each character has an equal probability of being chosen.

答:
i try create using css style, and it's work </p>

```<code><style>
  body {
    font-family: monospace;
    line-height:75%;
    letter-spacing:-3px;
  }
</style>
</code>```

<p>this php code : </p>

```<code><?php
  $i=10000;
  while($i) {
    if($i%200 == 0) echo '<br/>';
    echo chr(47 + 45 * rand(0,1));
    $i--;
  }
?>
</code>```

OwnerDisplayName: Judy

Body:
i try create using css style, and it's work

<style>
  body {
    font-family: monospace;
    line-height:75%;
    letter-spacing:-3px;
  }
</style>

this php code :

<?php
  $i=10000;
  while($i) {
    if($i%200 == 0) echo '<br/>';
    echo chr(47 + 45 * rand(0,1));
    $i--;
  }
?>


答:
R, 92 90 bytes

An R adaptation of @Leaky Nun's python answer. Working with strings in R is tedious as always.

```<code>n=scan();cat(rep(strsplit("I hate that I love that ","")[[1]],n)[6:(n*12)-5],"it.",sep="")
</code>```

This could probably be golfed further though.

Edit: saved 2 bytes by changing:

[1:((n*12)-5)]to [6:(n*12)-5]

Title: Hate/love conundrum

Body:
R, 92 90 bytes

An R adaptation of @Leaky Nun's python answer. Working with strings in R is tedious as always.

n=scan();cat(rep(strsplit("I hate that I love that ","")[[1]],n)[6:(n*12)-5],"it.",sep="")

This could probably be golfed further though.

Edit: saved 2 bytes by changing:

[1:((n*12)-5)]to [6:(n*12)-5]


问:
Catalan Numbers
The Catalan numbers (OEIS) are a sequence of natural numbers often appearing in combinatorics.

The nth Catalan number is the number of Dyck words (balanced strings of parenthesis or brackets such as [[][]]; formally defined as a string using two characters a and b such that any substring starting from the beginning has number of a characters greater than or equal to number of b characters, and the entire string has the same number of a and b characters) with length 2n. The nth Catalan number (for \$n\ge0\$) is also explicitly defined as:
$$C_n=\frac1{n+1}\binom{2n}n$$
Starting from \$n=0\$, the first 20 Catalan numbers are:

```<code>1, 1, 2, 5, 14, 42, 132, 429, 1430, 4862, 16796, 58786, 208012, 742900, 2674440, 9694845, 35357670, 129644790, 477638700, 1767263190...
</code>```

Challenge

Write a full program or function that takes a non-negative integer n via STDIN or an acceptable alternative, and outputs the nth Catalan number. Your program must work at minimum for inputs 0-19.

I/O

Input

Your program must take input from STDIN, function arguments or any of the acceptable alternatives per this meta post. You can read the inputted number as its standard decimal represention, unary representation, or bytes.

If (and only if) your language cannot take input from STDIN or any acceptable alternative, it may take input from a hardcoded variable or suitable equivalent in the program.

Output

Your program must output the nth Catalan number to STDOUT, function result or any of the acceptable alternatives per this meta post. You can output the Catalan number in its standard decimal representation, unary representation or bytes.

The output should consist of the approriate Catalan number, optionally followed by one or more newlines. No other output can be generated, except constant output of your language's interpreter that cannot be suppressed (such as a greeting, ANSI color codes or indentation).

This is not about finding the language that is the shortest. This is about finding the shortest program in every language. Therefore, I will not accept an answer.

In this challenge, languages newer than the challenge are acceptable as long as they have an implementation. It is allowed (and even encouraged) to write this interpreter yourself for a previously unimplemented language. Other than that, all the standard rules of code-golf must be obeyed. Submissions in most languages will be scored in bytes in an appropriate preexisting encoding (usually UTF-8). Note also that built-ins for calculating the nth Catalan number are allowed.

Catalog

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>## [><>](http://esolangs.org/wiki/Fish), 121 bytes
</code>```

 <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b">

Shortest Solution by Language

Language	User	Score

Leaderboard

	Author	Language	Size

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

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

```

答:
Oasis, 9 bytes

```<code>nxx«*n>÷1
</code>```

Try it online!

Oasis is a language designed by Adnan which is specialized in sequences.

Here, we shall use the following relationship kindly provided by Stefano Sanfilippo:

Currently, this language can do recursion and closed form.

To specify that a(0)=1 is simple: just add the 1 at the end.

For example, if a sequence begins with a(0)=0 and a(1)=1, just put 10 at the end.

Unfortunately, all sequences must be 0-indexed.

```<code>nxx«*n>÷1                        stack
        1  a(0)=1

n          push n (input)        n
 x         double                2n
  x        double                4n
   «       minus 2               4n-2
    *      multiply: second      (4n-2)*a(n-1)
           argument is missing,
           so a(n-1) is used.
     n     push n (input)        (4n-2)*a(n-1) n
      >    add 1                 (4n-2)*a(n-1) n+1
       ÷   integer division      (4n-2)*a(n-1)/(n+1)
                               = ((4n-2)/(n+1))*a(n-1)
                               = ((4n+4-6)/(n+1))*a(n-1)
                               = ((4n+4)/(n+1) - 6/(n+1))*a(n-1)
                               = (4-6/(n+1))*a(n-1)
</code>```

Closed-form:

10 bytes

```<code>nx!n!n>!*÷
</code>```

Try it online!

```<code>nx!n!n>!*÷

n           push n (input)
 x          double
  !         factorial: stack is now [(2n)!]
   n        push n (input)
    !       factorial: stack is now [(2n)! n!]
     n      push n (input)
      >     add 1
       !    factorial: stack is now [(2n)! n! (n+1)!]
        *   multiply: stack is now [(2n)! (n!(n+1)!)]
         ÷  divide: stack is now [(2n)!/(n!(n+1)!)]
</code>```

Title: Catalan Numbers

Body:
Oasis, 9 bytes

nxx«*n>÷1

Try it online!

Oasis is a language designed by Adnan which is specialized in sequences.

Here, we shall use the following relationship kindly provided by Stefano Sanfilippo:

Currently, this language can do recursion and closed form.

To specify that a(0)=1 is simple: just add the 1 at the end.

For example, if a sequence begins with a(0)=0 and a(1)=1, just put 10 at the end.

Unfortunately, all sequences must be 0-indexed.

nxx«*n>÷1                        stack
        1  a(0)=1

n          push n (input)        n
 x         double                2n
  x        double                4n
   «       minus 2               4n-2
    *      multiply: second      (4n-2)*a(n-1)
           argument is missing,
           so a(n-1) is used.
     n     push n (input)        (4n-2)*a(n-1) n
      >    add 1                 (4n-2)*a(n-1) n+1
       ÷   integer division      (4n-2)*a(n-1)/(n+1)
                               = ((4n-2)/(n+1))*a(n-1)
                               = ((4n+4-6)/(n+1))*a(n-1)
                               = ((4n+4)/(n+1) - 6/(n+1))*a(n-1)
                               = (4-6/(n+1))*a(n-1)

Closed-form:

10 bytes

nx!n!n>!*÷

Try it online!

nx!n!n>!*÷

n           push n (input)
 x          double
  !         factorial: stack is now [(2n)!]
   n        push n (input)
    !       factorial: stack is now [(2n)! n!]
     n      push n (input)
      >     add 1
       !    factorial: stack is now [(2n)! n! (n+1)!]
        *   multiply: stack is now [(2n)! (n!(n+1)!)]
         ÷  divide: stack is now [(2n)!/(n!(n+1)!)]


问:
Hofstadter Q-sequence

Definition

a(1) = 1

a(2) = 1

a(n) = a(n-a(n-1)) + a(n-a(n-2)) for n > 2 where n is an integer

Task

Given positive integer n, generate a(n).

Testcases

```<code>n  a(n)
1  1
2  1
3  2
4  3
5  3
6  4
7  5
8  5
9  6
10 6
11 6
12 8
13 8
14 8
15 10
16 9
17 10
18 11
19 11
20 12
</code>```

Reference

Obligatory OEIS A005185

答:
Oasis, <s>9</s> <s>7</s> 5 bytes

<s>Non-competing, since the language postdates the challenge.</s> Thanks to Kenny Lau for saving 4 bytes. Code:

```<code>ece+V
</code>```

Expanded form (V is short for 11):

```<code>a(n) = ece+
a(0) = 1
a(1) = 1
</code>```

Code:

```<code>e        # Stack is empty, so a(n - 1) is used, and it calculates a(n - a(n - 1))
 c       # Calculate a(n - 2)
  e      # Calculate a(n - a(n - 2))
   +     # Add up
</code>```

Try it online!. Calculates n = 1000 in 0.1 seconds.

Title: Hofstadter Q-sequence

Body:
Oasis, <s>9</s> <s>7</s> 5 bytes

<s>Non-competing, since the language postdates the challenge.</s> Thanks to Kenny Lau for saving 4 bytes. Code:

ece+V

Expanded form (V is short for 11):

a(n) = ece+
a(0) = 1
a(1) = 1

Code:

e        # Stack is empty, so a(n - 1) is used, and it calculates a(n - a(n - 1))
 c       # Calculate a(n - 2)
  e      # Calculate a(n - a(n - 2))
   +     # Add up

Try it online!. Calculates n = 1000 in 0.1 seconds.


答:
Perl 6, 65 bytes

```<code>{my \v=m:g/<[aeiou]>/;my @a=.comb;@a[v».from]=v.pick(*);@a.join}
</code>```

Anonymous function. Assumes lower-case input.

(try it online)

Title: Sheffle tho vawols ureund!

Body:
Perl 6, 65 bytes

{my \v=m:g/<[aeiou]>/;my @a=.comb;@a[v».from]=v.pick(*);@a.join}

Anonymous function. Assumes lower-case input.

(try it online)


问:
Traveling on a flat Earth
Coordinates in the flat-Earth world consist of latitude (x) and longitude (y), which are integers in the range 0...9999. Much like Gaussian integers, but they are always written using this notation:

```<code>411S 370E
</code>```

That is, with S or N appended to the latitude, and E or W appended to the longitude, with space(s) between the two components.

Goal

Write a program (not a function) that reads two coordinates, separated by whitespace, and outputs their sum. The first coordinate is a starting point, the second one is a displacement, and the output is the resulting position.

Input/Output

Since this challenge is partially about formatting, I'll try to define the input and output formats unambiguously.

The preferred input format has 1 space between the coordinate components, no leading zeros, and a newline character between the two coordinates. The program must be able to read the preferred format.

The output can contain any amount of whitespace and leading zeros. If it's different from the preferred input format, the program must be able to read this format too.

Just to make it clear, the input cannot (will not) contain any additional formatting characters. Just spaces and newlines where needed.

Scoring

This is an experiment on a new winning condition. I'll choose the winner by accepting an answer in a few weeks. If a better answer appears afterwards, I'll change the accepted answer.

The score for the program is its byte count. The winning program is one that is shorter than 400 bytes, has the fewest byte count, but is written in the most verbose programming language. To determine the winner:

Remove programs with byte count 400 or more (they can participate but cannot win)

Consider only the shortest program for each programming language

The longest program wins

Polyglots compete against programs in all languages in which they are valid (e.g. if a program is valid in both bash and sh, it competes against programs in both languages).

Test cases

In the test cases, the first two lines are the input, and the third line is the output.

```<code>0S 0E
0S 0W
0N 0E
</code>```

(the direction of zero doesn't matter, both in input and output)

```<code>0S 9999E
9999N 9999W
9999N 0E
</code>```

(maximal values)

```<code>42S 314W
42N 2718W
0N 3032W
</code>```

(the direction of zero doesn't matter in the output)

```<code>5555N 8888W
7777S 0E
2222S 8888W
</code>```

(no negative values; change the direction if you need to change the sign)

```<code>0001N        4545W
0999N        5454W
1000N        9999W
</code>```

(if the program outputs leading zeros and several spaces, it must be able to read them; it must also be able to read input that doesn't contain them)

```<code>8888N 8888W
9999N 9999W
</code>```

(invalid input - any behavior is acceptable, including crash and infinite loop)

答:
R, 196 bytes

R is pretty verbose, by golfing standards. Let's see...

```<code>i=scan(,'');l=nchar(i);S=W=`-`;N=E=c;n=as.double(substr(i,1,l-1));d=substr(i,l,l);for(j in 1:4)n[j]=get(d[j])(n[j]);o=c(n[1]+n[3],n[2]+n[4]);cat(paste0(abs(o), ifelse(o<0,c("S", "W"),c("N","E"))))
</code>```

Ungolfed:

```<code>input = scan(,'')       # Take input from stdin, separating at newlines and spaces
length = nchar(input)   # Get the number of characters in each input
S=W=`-`                 # These two lines create aliases of `-` (the minus function)
N=E=c                   # and c (the concatenate function).
                        # We will later treat the NSEW part of the coordinate
                        # as a call to a function, to ensure that the numbers
                        # are treated with the correct polarity.
numbers = as.double(substr(input, 1, length-1))
                        # Strip the last character off of every coordinate, convert
                        # to integer
directions = substr(input, length, length)
                        # Strip off the numbers and grab the cardinal directions
for(j in 1:4)
    numbers[j] = get(directions[j])(numbers[j])
                        # For our four numbers, treat the cardinal direction as
                        # a function, which is mapped to `-` for south and west, and
                        # `c` for north and east (which is essentially identity)
output = c(numbers[1]+numbers[3], numbers[2]+numbers[4])
                        # Add together the numbers
cat(paste0(abs(output), ifelse(output<0, c("S", "W"), c("N","E"))))
                        # Output the absolute values of the new coordinates, followed
                        # by "S" or "W" if the number is negative and "N" or "E" if
                        # the number is positive
</code>```

Edit to add: I just looked at the other answers, and I'm surprised that my entry is one of the shortest! Perhaps R isn't as verbose as I thought...

Title: Traveling on a flat Earth

Body:
R, 196 bytes

R is pretty verbose, by golfing standards. Let's see...

i=scan(,'');l=nchar(i);S=W=`-`;N=E=c;n=as.double(substr(i,1,l-1));d=substr(i,l,l);for(j in 1:4)n[j]=get(d[j])(n[j]);o=c(n[1]+n[3],n[2]+n[4]);cat(paste0(abs(o), ifelse(o<0,c("S", "W"),c("N","E"))))

Ungolfed:

input = scan(,'')       # Take input from stdin, separating at newlines and spaces
length = nchar(input)   # Get the number of characters in each input
S=W=`-`                 # These two lines create aliases of `-` (the minus function)
N=E=c                   # and c (the concatenate function).
                        # We will later treat the NSEW part of the coordinate
                        # as a call to a function, to ensure that the numbers
                        # are treated with the correct polarity.
numbers = as.double(substr(input, 1, length-1))
                        # Strip the last character off of every coordinate, convert
                        # to integer
directions = substr(input, length, length)
                        # Strip off the numbers and grab the cardinal directions
for(j in 1:4)
    numbers[j] = get(directions[j])(numbers[j])
                        # For our four numbers, treat the cardinal direction as
                        # a function, which is mapped to `-` for south and west, and
                        # `c` for north and east (which is essentially identity)
output = c(numbers[1]+numbers[3], numbers[2]+numbers[4])
                        # Add together the numbers
cat(paste0(abs(output), ifelse(output<0, c("S", "W"), c("N","E"))))
                        # Output the absolute values of the new coordinates, followed
                        # by "S" or "W" if the number is negative and "N" or "E" if
                        # the number is positive

Edit to add: I just looked at the other answers, and I'm surprised that my entry is one of the shortest! Perhaps R isn't as verbose as I thought...


答:
TSQL, 275 bytes

Golfed:

```<code>DECLARE @ VARCHAR(99)='the quick brown fox jumps over the lazy dog.'

;WITH c as(SELECT LEFT(@,0)x,0i UNION ALL SELECT LEFT(substring(@,i+1,1),1),i+1FROM c
WHERE i<LEN(@)),d as(SELECT *,rank()over(order by newid())a,row_number()over(order by 1/0)b
FROM c WHERE x IN('a','e','i','o','u'))SELECT @=STUFF(@,d.i,1,e.x)FROM d,d e
WHERE d.a=e.b PRINT @
</code>```

Ungolfed:

```<code>DECLARE @ VARCHAR(max)='the quick brown fox jumps over the lazy dog.'

;WITH c as
(
  SELECT LEFT(@,0)x,0i
  UNION ALL
  SELECT LEFT(substring(@,i+1,1),1),i+1
  FROM c
  WHERE i<LEN(@)
),d as
(
  SELECT
    *,
    rank()over(order by newid())a,
    row_number()over(order by 1/0)b
  FROM c
  WHERE x IN('a','e','i','o','u')
)
SELECT @=STUFF(@,d.i,1,e.x)FROM d,d e
WHERE d.a=e.b
-- next row will be necessary in order to handle texts longer than 99 bytes
-- not included in the golfed version, also using varchar(max) instead of varchar(99)
OPTION(MAXRECURSION 0)

PRINT @
</code>```

Fiddle

Title: Sheffle tho vawols ureund!

Body:
TSQL, 275 bytes

Golfed:

DECLARE @ VARCHAR(99)='the quick brown fox jumps over the lazy dog.'

;WITH c as(SELECT LEFT(@,0)x,0i UNION ALL SELECT LEFT(substring(@,i+1,1),1),i+1FROM c
WHERE i<LEN(@)),d as(SELECT *,rank()over(order by newid())a,row_number()over(order by 1/0)b
FROM c WHERE x IN('a','e','i','o','u'))SELECT @=STUFF(@,d.i,1,e.x)FROM d,d e
WHERE d.a=e.b PRINT @

Ungolfed:

DECLARE @ VARCHAR(max)='the quick brown fox jumps over the lazy dog.'

;WITH c as
(
  SELECT LEFT(@,0)x,0i
  UNION ALL
  SELECT LEFT(substring(@,i+1,1),1),i+1
  FROM c
  WHERE i<LEN(@)
),d as
(
  SELECT
    *,
    rank()over(order by newid())a,
    row_number()over(order by 1/0)b
  FROM c
  WHERE x IN('a','e','i','o','u')
)
SELECT @=STUFF(@,d.i,1,e.x)FROM d,d e
WHERE d.a=e.b
-- next row will be necessary in order to handle texts longer than 99 bytes
-- not included in the golfed version, also using varchar(max) instead of varchar(99)
OPTION(MAXRECURSION 0)

PRINT @

Fiddle


答:
Java 8, 23 bytes

```<code>n->n<900&(n-122)%111==1
</code>```

Ungolfed:

```<code>interface N { boolean f(int n); }

public static void main(String[] args) {
  N f = n ->
    n < 900 // 900 is not good
    &
    (n - 122) % 111 == 1 // force 12 to go negative and fail the comparison (can't use 123 because -111 % 111 == 0, while -110 % 111 == -1).
}
</code>```

Test class:

```<code>public class Main {
  private interface N {

    boolean f(int n);
  }

  static void test(N f, int n, boolean expected) {
    boolean result = f.f(n);
    System.out.printf("%s -> %b (%b) -> %s%n", n, result, expected, result == expected ? "OK" : "NOK");
  }

  public static void main(String[] args) {
    N f = n->n<900&(n-122)%111==1;

    test(f,  123, true);
    test(f,  234, true);
    test(f,  345, true);
    test(f,  456, true);
    test(f,  678, true);
    test(f,  789, true);

    test(f,    1, false);
    test(f,    2, false);
    test(f,    3, false);
    test(f,   12, false);
    test(f,  122, false);
    test(f,  124, false);
    test(f,  132, false);
    test(f,  321, false);
    test(f,  457, false);
    test(f,  777, false);
    test(f,  890, false);
    test(f,  900, false);
    test(f, 1011, false);
    test(f, 1230, false);
    test(f, 1234, false);

  }
}
</code>```

Title: As Easy as One-Two-Three

Body:
Write a program or function that takes in a positive integer. You can assume the input is valid and may take it as a string. If the number is any of

```<code>123
234
345
456
567
678
789
</code>```

then output a truthy value. Otherwise, output a falsy value. For example, the inputs

```<code>1
2
3
12
122
124
132
321
457
777
890
900
1011
1230
1234
</code>```

must all result in falsy output. (The input will not have leading zeroes so you needn't worry about things like 012.)

The shortest code in bytes wins.

Body:
Java 8, 23 bytes

n->n<900&(n-122)%111==1

Ungolfed:

interface N { boolean f(int n); }

public static void main(String[] args) {
  N f = n ->
    n < 900 // 900 is not good
    &
    (n - 122) % 111 == 1 // force 12 to go negative and fail the comparison (can't use 123 because -111 % 111 == 0, while -110 % 111 == -1).
}

Test class:

public class Main {
  private interface N {

    boolean f(int n);
  }

  static void test(N f, int n, boolean expected) {
    boolean result = f.f(n);
    System.out.printf("%s -> %b (%b) -> %s%n", n, result, expected, result == expected ? "OK" : "NOK");
  }

  public static void main(String[] args) {
    N f = n->n<900&(n-122)%111==1;

    test(f,  123, true);
    test(f,  234, true);
    test(f,  345, true);
    test(f,  456, true);
    test(f,  678, true);
    test(f,  789, true);

    test(f,    1, false);
    test(f,    2, false);
    test(f,    3, false);
    test(f,   12, false);
    test(f,  122, false);
    test(f,  124, false);
    test(f,  132, false);
    test(f,  321, false);
    test(f,  457, false);
    test(f,  777, false);
    test(f,  890, false);
    test(f,  900, false);
    test(f, 1011, false);
    test(f, 1230, false);
    test(f, 1234, false);

  }
}


答:
Retina, <s>42</s> 38 bytes

Thanks to Leaky Nun for helping me golf it!

```<code>11
1I love n
1
I hate n
n$
it.
n
that
</code>```

Input is taken in unary.

Try it online!

Explanation

```<code>11
1I love n
</code>```

Replace every pair of 1s with 1I love n.

```<code>1
I hate n
</code>```

Replace the remaining 1s with I hate n.

```<code>n$
it.
n
that
</code>```

Replace the n at the end of the line with it. and every other n with that .

Title: Hate/love conundrum

Body:
Challenge description

In this challenge, we only consider love and hate as feelings. If we want to utter a feeling expression of order N, we alternate between these two (starting with hate):

```<code>order | expression

1       I hate it.
2       I hate that I love it.
3       I hate that I love that I hate it.
4       I hate that I love that I hate that I love it.
</code>```

The pattern follows for every positive integer N. Given N, output the correspoinding feeling expression of order N.

Notes

Full stop (.) at the end of the expression is mandatory,

Trailing and leading whitespaces (including newlines) are permitted,

Output for a non-positive or non-integer N is undefined,

This is a code-golf challenge, so make your code as short as possible!

Body:
Retina, <s>42</s> 38 bytes

Thanks to Leaky Nun for helping me golf it!

11
1I love n
1
I hate n
n$
it.
n
that

Input is taken in unary.

Try it online!

Explanation

11
1I love n

Replace every pair of 1s with 1I love n.

1
I hate n

Replace the remaining 1s with I hate n.

n$
it.
n
that

Replace the n at the end of the line with it. and every other n with that .


问:
Swap bits with their neighbours

Task description

Given an integer, swap its (2k–1)-th and 2k-th least significant bits for all integers k > 0. This is sequence A057300 in the OEIS.

(The number is assumed to have “infinitely many” leading zeroes. In practice, this simply means prepending a single 0 bit to odd-length numbers.)

This is code-golf, so the shortest code (in bytes) wins.

Test cases

```<code>0 -> 0
1 -> 2
9 -> 6
85 -> 170
220 -> 236
1827 -> 2835
47525 -> 30298
</code>```

答:
Oasis, 17 bytes (non-competing)

```<code>n4÷axxn4÷xxe+3120
</code>```

Try it online!

Oasis is a language designed by Adnan which is specialized in sequences.

Currently, this language can do recursion and closed form.

We use this formula: a(4n+k) = 4a(n) + a(k), 0 <= k <= 3

To specify the base case is simple: the 3120 at the end simply means that a(0)=0, a(1)=2, a(2)=1, a(3)=3.

```<code>n4÷axxn4÷xxe+3120
                0  a(0) = 0
               2   a(1) = 2
              1    a(2) = 1
             3     a(3) = 3

n                  push n (input)
 4÷                integer-divide by 4
   a               a(n/4)
    xx             double twice; multiply by 4
                   now we have 4a(n/4)
      n            push n (input)
       4÷xx        integer-divide by 4 and then multiply by 4
                   since there is no modulo currently, n%4
                   is built as n-(n/4*4)
           e       we should have done a(n-(n/4*4)), but this
                   is a shortcut for a(n-x) where x is the top
                   of stack. Therefore, we now have a(n-n/4*4)
                   which is a(n%4).
            +      add.
</code>```

Title: Swap bits with their neighbours

Body:
Oasis, 17 bytes (non-competing)

n4÷axxn4÷xxe+3120

Try it online!

Oasis is a language designed by Adnan which is specialized in sequences.

Currently, this language can do recursion and closed form.

We use this formula: a(4n+k) = 4a(n) + a(k), 0 <= k <= 3

To specify the base case is simple: the 3120 at the end simply means that a(0)=0, a(1)=2, a(2)=1, a(3)=3.

n4÷axxn4÷xxe+3120
                0  a(0) = 0
               2   a(1) = 2
              1    a(2) = 1
             3     a(3) = 3

n                  push n (input)
 4÷                integer-divide by 4
   a               a(n/4)
    xx             double twice; multiply by 4
                   now we have 4a(n/4)
      n            push n (input)
       4÷xx        integer-divide by 4 and then multiply by 4
                   since there is no modulo currently, n%4
                   is built as n-(n/4*4)
           e       we should have done a(n-(n/4*4)), but this
                   is a shortcut for a(n-x) where x is the top
                   of stack. Therefore, we now have a(n-n/4*4)
                   which is a(n%4).
            +      add.


问:
There Was A Stream

 Challenge

Write a program that generates the song "There Was A Stream", detailed below.

 Description

The song "There Was a Stream" is a camping song. It takes N parameters and generates a song of length O(N2) lines. A sample song (first 3 verses) is given here.

 Rules

Your entry must take a list of strings and output a valid song. It may be a function (that takes an array of strings) or a program (that takes strings from ARGV or STDIN). Output may be a return value or output to STDOUT or STDERR.

It must run within 1/2 second on my machine (1.66GHz Intel Atom, 1GB RAM, Ubuntu 12.04) for all invocations with less than 15 parameters.

Verses must be separated by a blank line.

No inbuilt compression function (e.g. gzip), whether from the core or from libraries. Things like rot13, md5, base64 etc. are okay though.

You may include a data file (that is placed in the same directory and named whatever you wish), but its score will be added to the total for the program.

Scoring

Count the number of characters (if you use ASCII) or raw bytes (if you use something else).

Command-line flags (without the hyphens) are included, but not the interpreter name, for example #!/usr/bin/perl -n adds 1 to the character count. All whitespace is included.
As with all code-golf, the entry with the lowest character count wins.
Deadline: 14 December 2012

Example
```
INPUT: bank house
OUTPUT: (given above)```

Reference implementation (ungolfed, very ugly code): http://pastebin.com/VeR4Qttn

答:
Python 2.7 352 Bytes

```<code>import urllib as u;import re,sys;v=sys.argv;f=lambda l,o,n:[re.sub(o,n,i) for i in l];n='\n';d=-1;m=re.findall('i\d.+>(.+)</d',u.urlopen('http://goo.gl/48fMV').read());a=m[:8]+[n];z=range;s='stream'
for t in z(len(v)+d):a+=f(m,s,v[t])[9:11]+f(m,s,'little '+v[t+1])[:4]+['And the '+v[i+1]+' was on a '+v[i] for i in z(t,d,d)]+m[4:8]+[n]
print n.join(a)
</code>```

Example usage:

```<code>python stream bank house
</code>```

Output:

```<code>There was a stream
(There was a stream)
Just a teeny-weeny stream
(Just a teeny-weeny stream)
And the stream was on its way...
Where the moon shines high
In the clear blue sky
And all was bright and gay.

And on that stream
(And on that stream)
There was a little bank
(There was a little bank)
Just a teeny-weeny little bank
(Just a teeny-weeny little bank)
And the bank was on a stream
And the stream was on its way...
Where the moon shines high
In the clear blue sky
And all was bright and gay.

And on that bank
(And on that bank)
There was a little house
(There was a little house)
Just a teeny-weeny little house
(Just a teeny-weeny little house)
And the house was on a bank
And the bank was on a stream
And the stream was on its way...
Where the moon shines high
In the clear blue sky
And all was bright and gay.
</code>```

Un-golfed (also added a few a+=s):

```<code>#!/usr/bin/env python

import urllib as u
import re
import sys

v=sys.argv

f=lambda l,o,n: [re.sub(o,n,i) for i in l]

n='\n';
d=-1;
m=re.findall('i\d.+>(.+)</d',u.urlopen('http://goo.gl/48fMV').read())
a=m[:8]+[n]
z=range
s='stream'

for t in z(len(v)+d):
    a+=f(m,s,v[t])[9:11]
    a+=f(m,s,'little '+v[t+1])[:4]
    a+=['And the '+v[i+1]+' was on a '+v[i] for i in z(t,d,d)]
    a+=m[4:8]+[n]
print n.join(a)
</code>```

Title: There Was A Stream

Body:
Python 2.7 352 Bytes

import urllib as u;import re,sys;v=sys.argv;f=lambda l,o,n:[re.sub(o,n,i) for i in l];n='\n';d=-1;m=re.findall('i\d.+>(.+)</d',u.urlopen('http://goo.gl/48fMV').read());a=m[:8]+[n];z=range;s='stream'
for t in z(len(v)+d):a+=f(m,s,v[t])[9:11]+f(m,s,'little '+v[t+1])[:4]+['And the '+v[i+1]+' was on a '+v[i] for i in z(t,d,d)]+m[4:8]+[n]
print n.join(a)

Example usage:

python stream bank house

Output:

There was a stream
(There was a stream)
Just a teeny-weeny stream
(Just a teeny-weeny stream)
And the stream was on its way...
Where the moon shines high
In the clear blue sky
And all was bright and gay.

And on that stream
(And on that stream)
There was a little bank
(There was a little bank)
Just a teeny-weeny little bank
(Just a teeny-weeny little bank)
And the bank was on a stream
And the stream was on its way...
Where the moon shines high
In the clear blue sky
And all was bright and gay.

And on that bank
(And on that bank)
There was a little house
(There was a little house)
Just a teeny-weeny little house
(Just a teeny-weeny little house)
And the house was on a bank
And the bank was on a stream
And the stream was on its way...
Where the moon shines high
In the clear blue sky
And all was bright and gay.

Un-golfed (also added a few a+=s):

#!/usr/bin/env python

import urllib as u
import re
import sys

v=sys.argv

f=lambda l,o,n: [re.sub(o,n,i) for i in l]

n='\n';
d=-1;
m=re.findall('i\d.+>(.+)</d',u.urlopen('http://goo.gl/48fMV').read())
a=m[:8]+[n]
z=range
s='stream'

for t in z(len(v)+d):
    a+=f(m,s,v[t])[9:11]
    a+=f(m,s,'little '+v[t+1])[:4]
    a+=['And the '+v[i+1]+' was on a '+v[i] for i in z(t,d,d)]
    a+=m[4:8]+[n]
print n.join(a)


答:
MaxBot, Java

This bot tries to make the most profit out of each transaction. While selling, puts the price of an unknown stock at $300, when buying $250.

```<code>import java.util.List;
import com.ppcg.stockexchange.*;
public class MaxBot extends Player {
    int toSell;
    int sellPrice;

    public void secretValue(int stockType, int value) {
        super.secretValue(stockType, value);
        toSell = stockType;
        sellPrice = (value + 1000)/2;
    }
    public Offer acceptOffer(List<Offer> offers) {
        Offer max = null;
        int maxDif = 0;
        for(Offer o: offers){
            int price = secretStockType == o.getOffer().getType()? secretStockValue: 250;
            int val = price * o.getOffer().getAmount();
            int dif = val - o.getPayment();
            if(maxDif < dif){
                max = o;
                maxDif = dif;
            }
        }
        return max;
    }
    public Offer makeOffer(List<Stock> currentStock){
        if(toSell == -1){
            return null;
        }
        int sum = 0;
        for (Stock s: currentStock){
            if(s.getType() == toSell){
                sum += s.getAmount;
            }
        }
        int n = sum - sum/2;
        return new Offer(new Stock(toSell, n), n * sellPrice);
    }
    public void acceptedOffers(List<Offer> acceptedOffers) {
        int highStock = -1;
        int highPrice = 0;
        int markup = 0;
        for(Offer o: offers){
            int trueVal = secretStockType == o.getOffer().getType()? secretStockValue: 250;
            int marketVal = o.getPayment()/o.getOffer().getAmount();
            if(marketVal - trueVal > markup){
                highStock = o.getOffer().getType();
                highPrice = marketVal;
                markup = marketVal - trueVal;
            }
        }
        toSell = highStock;
    }
}
</code>```

Title: Stock Exchange KoTH

Body:
The stock market is all about the speed of knowledge. Unlike previous challenges, the current stock price is not random: it is determined by those playing the game.  If you can identify an under-priced stock before anybody else, then you've written yourself a money-making program.

Price refers to the how much people are trading the stock for, while Value refers to the amount the stock is worth at the end of the game.

Each player starts with 1000 of each stock, and 0 relative net worth.  Each stock has a secret value, and your score at the end of the game is (stockValue for each ownedStock) + netWorth.  Your net worth can be negative.  In an N-player game, there are N stocks.

Steps:

The game follows the following steps:

You are given the secret value of a single stock.

You make an offer to sell X of Y stock for $Z

All players are given the offers, and each may choose one to accept

All players are informed of accepted offers

Go back to step 2

Each of the steps are given in detail below:

void secretValue(int stockType, int value):

The value you learn is not revealed to any other player.

The value is between 0 and 1000

Low values are more like to occur than high values (squared uniform distribution)

Offer makeOffer(List<Stock> currentStock)

You can return null to make no offer.

Offer acceptOffer(List<Offer> offers)

You can return null to accept none of them

If there are no available offers, this will not be called

If you accept, your net worth goes down by $Z (can go negative) and receive X of Y stock.  The opposite occurs with the seller.

If you accept an offer, the exchange will occur immediately, and the offer will be removed so additional players cannot accept it.

void acceptedOffers(List<Offer> offers)

Includes your accepted offers as well

Static variables or writing to files is not allowed.  (No persistent data from game to game)  Non-serious contenders are allowed.

Interfaces:

```<code>public final class Stock {
    public Stock(int stockType, int amount);
    public int getType();
    public int getAmount();
    public Stock minus(Stock other);
    public Stock plus(Stock other);
    public Stock minus(int amount);
    public Stock plus(int amount);
    public Stock setAmount(int amount);
}
public class Offer {
    public Offer(Stock offer, int payment);
    public Stock getOffer();
    public int getPayment();
}
</code>```

Non-Java submissions:

All calls consist of two lines: The first line is the function being called: SecretValue, MakeOffer, AcceptOffer, AcceptedOffers, SetRandom, and the second line containing the actual data.

Stocks are formatted with a : delimiter: stockType:stockAmount.

Offers are formatted with a @ delimiter: offer@price

Lists are formatted with a ; delimiter

SecretValue is formatted with a : delimiter: stockType:value

RandomSeed is used to make your submission deterministic.  If your submission uses randomness, please use the integer value passed as the seed!

All function calls need a response.  If the response is null or void, return an empty string.

Please include a command.txt that gives the command line arguments to run your submission

Scoring

Games consisting of 1000 turns will be run multiple times.  Players will be scored according to the ELO system, and paired with players of similar skill levels.  The player with the highest final ELO score wins!  (I've modified the system so that each game, ELO scores are updated for each player pairing)

The controller includes an autodownloader, so please start your submission with a header: Name, Language.  If your submission is not in Java, each code block should start with the name of the file.  (excluding the command file, which should be the first block in your post)

Running

There are 2 ways to run this project:

Download the source code, compile and run.  You can find the source on Github.  Run git clone --recursive https://github.com/nathanmerrill/StockExchange.git

Download the JAR executable.  Submissions should be placed in your current working directory in the /submissions folder.  You can download just the JAR, just the submissions, or both

Pass in run to run the project (default option), or pass in download to download all submissions so far from this question.

Scoreboard

```<code>1.  1308.1220497323848  Cheater
2.  1242.0333695640356  InsideTrader
3.  1158.3662658295411  UncleScrooge
4.  1113.8344000358493  BlackMarket
5.  1051.8370015258993  DartMonkey
6.  983.0545446731494   WarGamer
7.  939.457423938002    Spammer
8.  901.4372529538886   DumbBot
9.  859.0519326039137   ShutUpAndTakeMyMoney
10. 852.9448222849587   VincentKasuga
11. 718.2112067329083   Profiteer
</code>```

Body:
MaxBot, Java

This bot tries to make the most profit out of each transaction. While selling, puts the price of an unknown stock at $300, when buying $250.

import java.util.List;
import com.ppcg.stockexchange.*;
public class MaxBot extends Player {
    int toSell;
    int sellPrice;

    public void secretValue(int stockType, int value) {
        super.secretValue(stockType, value);
        toSell = stockType;
        sellPrice = (value + 1000)/2;
    }
    public Offer acceptOffer(List<Offer> offers) {
        Offer max = null;
        int maxDif = 0;
        for(Offer o: offers){
            int price = secretStockType == o.getOffer().getType()? secretStockValue: 250;
            int val = price * o.getOffer().getAmount();
            int dif = val - o.getPayment();
            if(maxDif < dif){
                max = o;
                maxDif = dif;
            }
        }
        return max;
    }
    public Offer makeOffer(List<Stock> currentStock){
        if(toSell == -1){
            return null;
        }
        int sum = 0;
        for (Stock s: currentStock){
            if(s.getType() == toSell){
                sum += s.getAmount;
            }
        }
        int n = sum - sum/2;
        return new Offer(new Stock(toSell, n), n * sellPrice);
    }
    public void acceptedOffers(List<Offer> acceptedOffers) {
        int highStock = -1;
        int highPrice = 0;
        int markup = 0;
        for(Offer o: offers){
            int trueVal = secretStockType == o.getOffer().getType()? secretStockValue: 250;
            int marketVal = o.getPayment()/o.getOffer().getAmount();
            if(marketVal - trueVal > markup){
                highStock = o.getOffer().getType();
                highPrice = marketVal;
                markup = marketVal - trueVal;
            }
        }
        toSell = highStock;
    }
}