答:
Actually, 16 bytes

```<code>;$╗`P$╜@íu`╓dP.X
</code>```

Try it online!

Explanation:

```<code>;$╗`P$╜@íu`╓dP.X
;$╗               make a copy of n, push str(n) to reg0
   `      `╓      push the first n values where f(k) is truthy, starting with k=0:
    P$              kth prime, stringified
      ╜@íu          1-based index of n, 0 if not found
            d     remove last element of list and push it to the stack (dequeue)
             P    nth prime
              .   print
               X  discard rest of list
</code>```

Title: Print the nth prime that contains n

Body:
This question will be a twist on finding the nth prime number.

Challenge

You must write a program that will take one input n, and output the nth prime number whose decimal representation contains the decimal representation of n as a subtring.

Confused? Here are some examples.

```<code>n=1
Primes: 2, 3, 5, 7, 11
                    ^1 first prime that contains a 1
Output: 11

n=2
Primes: 2, 3, 5, 7, 11, 13, 17, 19, 23
        ^1                          ^2 second prime that contains a 2
Output: 23

n=3
Primes: 2, 3, 5, 7, 11, 13, 17, 19, 23
           ^1           ^2          ^3 third prime that contains a 3
Output: 23

n=10
Primes: 2, 3, 5, 7, 11, ..., 97, 101, 103, 107, 109, ..., 997, 1009, 1013, 1019, 1021, 1031, 1033
                                 ^1   ^2   ^3   ^4             ^5    ^6    ^7    ^8    ^9    ^10 tenth prime that contains a 10
Output: 1033
</code>```

This is code-golf, so lowest byte count wins.

If something is confusing, please leave a comment.

Body:
Actually, 16 bytes

;$╗`P$╜@íu`╓dP.X

Try it online!

Explanation:

;$╗`P$╜@íu`╓dP.X
;$╗               make a copy of n, push str(n) to reg0
   `      `╓      push the first n values where f(k) is truthy, starting with k=0:
    P$              kth prime, stringified
      ╜@íu          1-based index of n, 0 if not found
            d     remove last element of list and push it to the stack (dequeue)
             P    nth prime
              .   print
               X  discard rest of list


问:
The Nine Pattern

Introduction

I stumbled across this (useless) pattern the other day while I was watching TV.
I named it "the 9 pattern" because the first number to use it was 9.
The gist of it is, you enter a number (let's say x), and then you get back:

x

x + (x / 3) [let's call this y]

two-thirds of y [let's call this z]

z + 1

So, if I put inside this pattern the number 9 as x, this is what would come out:

9 (9)

12 (9 + 9 / 3) [9 over 3 is 3, and 9 + 3 is 12]

8 (12 times two-thirds) [a third of 12 is 4, and 4 * 2 is 8]

9 (8 + 1 is 9)

Challenge

Write me a function (in any programming language) that takes in a number, and outputs an integer array using the pattern.

Somewhat like this psuedo-code:

```<code>function ninePattern(int myInt) returns IntegerArray {
    int iterationA = myInt + (myInt / 3);
    int iterationB = iterationA * (2 / 3);
    int iterationC = iterationB + 1;
    IntegerArray x = [myInt, iterationA, iterationB, iterationC];
    return x;
}
</code>```

Clarifications

Discussions have been arousing in comments regarding the specifications of the question. This section is meant to clarify some of those.

"better to count in bytes than characters"

I picked characters because (for me, at least) it would be easier to judge. Of course, I can't change that now. (lots of answers are already posted)

"rounding"

Rounding follows this rhyme:

If it's 5 or more, raise the score

  If it's 4 or less, let it rest

Simply, put, if it is something like 4.7 or 3.85, round them to 5 and 4 respectively.

Examples

```<code>Input => Result
9 => [9, 12, 8, 9]
8 => [8, 11, 7, 8]
6 => [6, 8, 5, 6]
23 => [23, 31, 21, 22]
159 => [159, 212, 141, 142]
</code>```

If, however, the numbers are something like 2.3 or 10.435446, round them to 2 and 10 respectively.

"language support"

You are free to not use functions and/or arrays IF AND ONLY IF the language of your choice does not support them.  If it does (even if it will increase your characters count), you must use them.

答:
Cheddar, 27 bytes

```<code>b=8/9*$0
[$0,$0+$0/3,b,b+1]
</code>```

$0 is variable with input. Cheddar just isn't a golfy language ¯\_(ツ)_/¯ , also this is non-competing because Cheddar's input functionality was made after this challenge.

Ungolfed:

```<code>IterationB := 8 / 9 * $0  // 8/9ths of the Input
[ $0,                     // The input
  $0 + $0 / 3,            // Input + (Input/3)
  IterationB,             // (see above)
  IterationB + 1          // above + 1
]
</code>```

ContentLicense: CC BY-SA 3.0

Title: The Nine Pattern

Body:
Cheddar, 27 bytes

b=8/9*$0
[$0,$0+$0/3,b,b+1]

$0 is variable with input. Cheddar just isn't a golfy language ¯\_(ツ)_/¯ , also this is non-competing because Cheddar's input functionality was made after this challenge.

Ungolfed:

IterationB := 8 / 9 * $0  // 8/9ths of the Input
[ $0,                     // The input
  $0 + $0 / 3,            // Input + (Input/3)
  IterationB,             // (see above)
  IterationB + 1          // above + 1
]


问:
Simple cat program
One of the most common standard tasks (especially when showcasing esoteric programming languages) is to implement a "cat program": read all of STDIN and print it to STDOUT. While this is named after the Unix shell utility cat it is of course much less powerful than the real thing, which is normally used to print (and concatenate) several files read from disc.

Task

You should write a full program which reads the contents of the standard input stream and writes them verbatim to the standard output stream. If and only if your language does not support standard input and/or output streams (as understood in most languages), you may instead take these terms to mean their closest equivalent in your language (e.g. JavaScript's prompt and alert). These are the only admissible forms of I/O, as any other interface would largely change the nature of the task and make answers much less comparable.

The output should contain exactly the input and nothing else. The only exception to this rule is constant output of your language's interpreter that cannot be suppressed, such as a greeting, ANSI color codes or indentation. This also applies to trailing newlines. If the input does not contain a trailing newline, the output shouldn't include one either! (The only exception being if your language absolutely always prints a trailing newline after execution.)

Output to the standard error stream is ignored, so long as the standard output stream contains the expected output. In particular, this means your program can terminate with an error upon hitting the end of the stream (EOF), provided that doesn't pollute the standard output stream. If you do this, I encourage you to add an error-free version to your answer as well (for reference).

As this is intended as a challenge within each language and not between languages, there are a few language specific rules:

If it is at all possible in your language to distinguish null bytes in the standard input stream from the EOF, your program must support null bytes like any other bytes (that is, they have to be written to the standard output stream as well).

If it is at all possible in your language to support an arbitrary infinite input stream (i.e. if you can start printing bytes to the output before you hit EOF in the input), your program has to work correctly in this case. As an example yes | tr -d \\n | ./my_cat should print an infinite stream of ys. It is up to you how often you print and flush the standard output stream, but it must be guaranteed to happen after a finite amount of time, regardless of the stream (this means, in particular, that you cannot wait for a specific character like a linefeed before printing).

Please add a note to your answer about the exact behaviour regarding null-bytes, infinite streams, and extraneous output.

Additional rules

This is not about finding the language with the shortest solution for this (there are some where the empty program does the trick) - this is about finding the shortest solution in every language. Therefore, no answer will be marked as accepted.

Submissions in most languages will be scored in bytes in an appropriate preexisting encoding, usually (but not necessarily) UTF-8.

Some languages, like Folders, are a bit tricky to score. If in doubt, please ask on Meta.

Feel free to use a language (or language version) even if it's newer than this challenge. Languages specifically written to submit a 0-byte answer to this challenge are fair game but not particularly interesting.

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.

Also note that languages do have to fulfil our usual criteria for programming languages.

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 Headsecks or Unary), consider adding a note to the existing answer that the same or a very similar solution is also the shortest in the other language.

Unless they have been overruled earlier, all standard code-golf rules apply, including the http://meta.codegolf.stackexchange.com/q/1061.

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 author actually had to put effort into golfing the code.

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>## [><>](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

```

答:
Archway, 7 bytes

```<code>/.\
\,/
</code>```

According to Esolangs, this is the only useful program that can be written in the original Archway language.

Title: Simple cat program

Body:
Archway, 7 bytes

/.\
\,/

According to Esolangs, this is the only useful program that can be written in the original Archway language.


Title: Simple cat program

Body:
One of the most common standard tasks (especially when showcasing esoteric programming languages) is to implement a "cat program": read all of STDIN and print it to STDOUT. While this is named after the Unix shell utility cat it is of course much less powerful than the real thing, which is normally used to print (and concatenate) several files read from disc.

Task

You should write a full program which reads the contents of the standard input stream and writes them verbatim to the standard output stream. If and only if your language does not support standard input and/or output streams (as understood in most languages), you may instead take these terms to mean their closest equivalent in your language (e.g. JavaScript's prompt and alert). These are the only admissible forms of I/O, as any other interface would largely change the nature of the task and make answers much less comparable.

The output should contain exactly the input and nothing else. The only exception to this rule is constant output of your language's interpreter that cannot be suppressed, such as a greeting, ANSI color codes or indentation. This also applies to trailing newlines. If the input does not contain a trailing newline, the output shouldn't include one either! (The only exception being if your language absolutely always prints a trailing newline after execution.)

Output to the standard error stream is ignored, so long as the standard output stream contains the expected output. In particular, this means your program can terminate with an error upon hitting the end of the stream (EOF), provided that doesn't pollute the standard output stream. If you do this, I encourage you to add an error-free version to your answer as well (for reference).

As this is intended as a challenge within each language and not between languages, there are a few language specific rules:

If it is at all possible in your language to distinguish null bytes in the standard input stream from the EOF, your program must support null bytes like any other bytes (that is, they have to be written to the standard output stream as well).

If it is at all possible in your language to support an arbitrary infinite input stream (i.e. if you can start printing bytes to the output before you hit EOF in the input), your program has to work correctly in this case. As an example yes | tr -d \\n | ./my_cat should print an infinite stream of ys. It is up to you how often you print and flush the standard output stream, but it must be guaranteed to happen after a finite amount of time, regardless of the stream (this means, in particular, that you cannot wait for a specific character like a linefeed before printing).

Please add a note to your answer about the exact behaviour regarding null-bytes, infinite streams, and extraneous output.

Additional rules

This is not about finding the language with the shortest solution for this (there are some where the empty program does the trick) - this is about finding the shortest solution in every language. Therefore, no answer will be marked as accepted.

Submissions in most languages will be scored in bytes in an appropriate preexisting encoding, usually (but not necessarily) UTF-8.

Some languages, like Folders, are a bit tricky to score. If in doubt, please ask on Meta.

Feel free to use a language (or language version) even if it's newer than this challenge. Languages specifically written to submit a 0-byte answer to this challenge are fair game but not particularly interesting.

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.

Also note that languages do have to fulfil our usual criteria for programming languages.

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 Headsecks or Unary), consider adding a note to the existing answer that the same or a very similar solution is also the shortest in the other language.

Unless they have been overruled earlier, all standard code-golf rules apply, including the http://meta.codegolf.stackexchange.com/q/1061.

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 author actually had to put effort into golfing the code.

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>## [><>](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

```

Body:
Archway 2, 19 bytes

   \
// .
  , /
+/\


问:
The game of Sevens! Who said what?
The game of Sevens is played as follows: n players sit in a circle, and start counting up from 1, passing to the left (or from player A to player B).

When a number p that has a 7 in it OR is divisible by 7 is reached, then the player who spoke the number p-1, after the next player says p, must say p+1 and the order of people speaking reverses. For example, if player B speaks 6, player C says 7, B says 8, and player A says 9.

Note: For those who want to play in real life, if a person forgets a number (or in the version where sevens are not said, accidentally says a seven), they are eliminated from the circle, but we will omit this detail from this challenge.

The challenge itself is to print which numbers each player should say in a perfect game of Sevens up to an input m for an input n players.

As an example, where five people, A, B, C, D, and E, are to play till they reach 30. They play in this manner

```<code>A: 1 6 8 13    15 19       23    30
B: 2 7*  12    16 18       24
C: 3     11    17*         25
D: 4     10          21*   26 28*
E: 5      9 14*      20 22 27*29
</code>```

where sevens are marked with *. Note that at 27 and 28, we're reversing twice, and play continues "as normal" from D to E.

Please note that the output does not have to be in the above format. I simply printed it that way for some clarity.

Rules

The input is two integers in any order, m representing the last number to say, n representing the number of players.

The output can be several arrays or several strings, one for each player. If you use strings, you do not have to use separators (though, if you could add some in your code tests, we would appreciate the readability). If you can actually print them in a circle somehow, that is acceptable as well, and it would be pretty cool too.

The output does not have to designate which players are which (it's fairly obvious that the first player is the one who says 1), though if the output isn't sorted for whatever reason, you should make clear which player is speaking which set of numbers. Omitting players who do not say anything is also allowed if you make it clear which players are speaking. I will add some more examples of possible outputs below.

This is code golf, so the smallest number of bytes wins.

As always, if the problem is unclear, please let me know. Good luck and good golfing!

Examples

```<code>>>> sevens_string(30, 5, " ")
'1 6 8 13 15 19 23 30'
'2 7 12 16 18 24'
'3 11 17 25'
'4 10 21 26 28'
'5 9 14 20 22 27 29'
>>> sevens_string(42, 5)
'16813151923303539'
'27121618243140'
'31117253241'
'410212628333742'
'591420222729343638'
>>> sevens_array(20, 3)
[1, 4, 7, 10, 13, 15, 19]
[2, 5, 9, 12, 16, 18]
[3, 6, 8, 11, 14, 17, 20]
>>> sevens_array(18, 10)
[1, 13, 15]
[2, 12, 16, 18]
[3, 11, 17]
[4, 10]
[5, 9]
[6, 8]
[7]
[]
[]
[14]
</code>```

Title: The game of Sevens! Who said what?

Body:
Dyalog APL, <s>50</s> <s>47</s> 35 bytes

{,⌸⍵|+\0,¯1*+\{0=7|⍵×~7∊⍎¨⍕⍵}¨⍳⍺-1}

This displays the numbers each player said as a table, where the first column enumerates the players. Rows are padded with 0s to the same length, and rows without numbers are omitted.

Verification

      f ← {,⌸⍵|+\0,¯1*+\{0=7|⍵×~7∊⍎¨⍕⍵}¨⍳⍺-1}
      30 f 5
0 1  6  8 13 15 19 23 30
1 2  7 12 16 18 24  0  0
2 3 11 17 25  0  0  0  0
3 4 10 21 26 28  0  0  0
4 5  9 14 20 22 27 29  0
      42 f 5
0 1  6  8 13 15 19 23 30 35 39
1 2  7 12 16 18 24 31 40  0  0
2 3 11 17 25 32 41  0  0  0  0
3 4 10 21 26 28 33 37 42  0  0
4 5  9 14 20 22 27 29 34 36 38
      20 f 3
0 1 4 7 10 13 15 19
1 2 5 9 12 16 18  0
2 3 6 8 11 14 17 20
      14 f 10
0  1 13
1  2 12
2  3 11
3  4 10
4  5  9
5  6  8
6  7  0
9 14  0

Note that, in the last example, 7 and 8 are omitted since those players haven't said anything yet.


问:
Find the n-th perfect power!
A perfect power is a number of the form \$a^b\$, where \$a>0\$ and \$b>1\$.

For example, \$125\$ is a perfect power because it can be expressed as \$5^3\$.

Goal

Your task is to write  a program/function that finds the \$n\$-th perfect power, given a positive integer \$n\$.

Specs

The first perfect power is \$1\$ (which is \$1^2\$).

Input/output in any reasonable format.

Built-ins are allowed.

Further information

OEIS A001597

Scoring

This is code-golf. Shortest solution in bytes wins.

Testcases

```<code>input  output
1      1
2      4
3      8
4      9
5      16
6      25
7      27
8      32
9      36
10     49
</code>```

ContentLicense: CC BY-SA 4.0

Title: Find the n-th perfect power!

Body:
Java, 126

r->{int n,i,k;if(r==1)return r;for(n=i=2,r--;;){for(k=i*i;k<=n;k*=i)if(k==n){i=--r>0?++n:n;if(r<1)return n;}if(--i<2)i=++n;}}


答:
Python 3, 45 bytes

```<code>f=lambda i:map(round,[i,i*4/3,i*8/9,i*8/9+1])
</code>```

See this code running on ideone.com

Title: The Nine Pattern

Body:
Introduction

I stumbled across this (useless) pattern the other day while I was watching TV.
I named it "the 9 pattern" because the first number to use it was 9.
The gist of it is, you enter a number (let's say x), and then you get back:

x

x + (x / 3) [let's call this y]

two-thirds of y [let's call this z]

z + 1

So, if I put inside this pattern the number 9 as x, this is what would come out:

9 (9)

12 (9 + 9 / 3) [9 over 3 is 3, and 9 + 3 is 12]

8 (12 times two-thirds) [a third of 12 is 4, and 4 * 2 is 8]

9 (8 + 1 is 9)

Challenge

Write me a function (in any programming language) that takes in a number, and outputs an integer array using the pattern.

Somewhat like this psuedo-code:

```<code>function ninePattern(int myInt) returns IntegerArray {
    int iterationA = myInt + (myInt / 3);
    int iterationB = iterationA * (2 / 3);
    int iterationC = iterationB + 1;
    IntegerArray x = [myInt, iterationA, iterationB, iterationC];
    return x;
}
</code>```

Clarifications

Discussions have been arousing in comments regarding the specifications of the question. This section is meant to clarify some of those.

"better to count in bytes than characters"

I picked characters because (for me, at least) it would be easier to judge. Of course, I can't change that now. (lots of answers are already posted)

"rounding"

Rounding follows this rhyme:

If it's 5 or more, raise the score

  If it's 4 or less, let it rest

Simply, put, if it is something like 4.7 or 3.85, round them to 5 and 4 respectively.

Examples

```<code>Input => Result
9 => [9, 12, 8, 9]
8 => [8, 11, 7, 8]
6 => [6, 8, 5, 6]
23 => [23, 31, 21, 22]
159 => [159, 212, 141, 142]
</code>```

If, however, the numbers are something like 2.3 or 10.435446, round them to 2 and 10 respectively.

"language support"

You are free to not use functions and/or arrays IF AND ONLY IF the language of your choice does not support them.  If it does (even if it will increase your characters count), you must use them.

Body:
Python 3, 45 bytes

f=lambda i:map(round,[i,i*4/3,i*8/9,i*8/9+1])

See this code running on ideone.com


答:
Lua, 52 Bytes

This program takes a number by command-line argument and return the corresponding array.
Programs in lua are technically functions, as the interpreter will always encapsulate them in a function. This is also this mechanic that is used when you "call" codes in other files (it basically uses loadfile/dofile).

m=math.floor x=...z=m(x*8/9)return{x,m(x*4/3),z,z+1}
```

Title: The Nine Pattern


问:
Golf a golf-scorer
As a kid, I used to play the card game "golf" a lot. Your challenge, should you choose to accept it, is to calculate the score of a golf hand. Since there are over 9000 variations on this card game1, we will go with the rules I remember playing.

Rules (of the game)

You end a round with 6 cards, and you want as few points as possible.

Jokers are not used.

Aces and 2s are worth -1, and -2 points respectively.

Jacks and Kings are both worth 0 points.

Cards from 3 to 10 are worth face value. However, these are cancelled when you pair them off. For example, a 5 is worth 5 points, but two 5s are worth zero. Three 5s are worth 5 points, (since the first 2 are paired off, but the 3rd is not.) and four 5s are worth 0 (since it makes 2 pairs).

Queens are worth 15 points. Queens cannot be cancelled, e.g. 2 queens are worth 30 points.

Rules (of the challenge)

Input will be an array of integers, or 6 individual integers. Whichever one you prefer. 1 represents an ace, 2-10 represents 2-10, and Jack, Queen, and King represents 11, 12, and 13. Output is the score of the hand according to the rules above. You can safely assume that all inputs are valid, e.g. no number appears more than 4 times, and all numbers are in the range [1, 13]. Input and output can be in any reasonable format.

Test IO:

```<code>[11, 10, 3, 1, 2, 2]    --> 8
[4, 5, 5, 3, 8, 7]      --> 22
[2, 2, 2, 2, 1, 1]      --> -10 (The lowest score possible)
[12, 12, 12, 12, 10, 9] --> 79 (The highest score possible)
[9, 9, 9, 9, 11, 1]     --> -1
[8, 8, 8, 8, 11, 13]    --> 0
[10, 9, 3, 7, 12, 2]    --> 42
[1, 2, 3, 4, 5, 6]      --> 15
[10, 9, 2, 3, 4, 1]     --> 23
[10, 3, 12, 3, 7, 12]   --> 47
</code>```

Shortest answer in bytes wins!

1not really, but there are a lot of variations.

Title: Golf a golf-scorer

Body:
JavaScript (ES6), 63 bytes

a=>a.map(e=>r+=e<3?-e:e>10?e-12?0:15:(m[e]^=1)?e:-e,r=0,m=[])|r

Or if you prefer,

a=>a.map(e=>r-=e<3?e:e>10?e-12?0:-15:(m[e]^=1)?-e:e,r=0,m=[])|r


问:
Greatest Number in a Range When The Sum of Squares of its Prime Factors are Subtracted
The formula

Take for instance the number 300

The prime factors of 300 are [2, 3, 5] (unique numbers that are
factors of 300 and prime)

Squaring each of those numbers will give
you [4, 9, 25]

Summing that list will give you 4 + 9 + 25 = 38

Finally subtract that sum (38) from your original number 300-38 = 262 (this is the result)

Input

Your input will be a positive integer greater than 2. You must check all numbers from 2 to the input value (inclusive) and find the number that produces the greatest result with the formula above.

Output

Your output will be two numbers separated by a space, comma, newline or whatever you language allows (the separation is necessary to distinguish the two numbers). These can be output to a file, stdout, or whatever your language uses. Your goal is to find the number in the range that produces the maximum output when run through the formula above. The first number displayed should be the starting number (like 300) and the second number should be the output that the formula produced (like 262)

Test Cases

```<code>Input: 3       Output: 2, -2
Input: 10      Output: 8, 4
Input: 50      Output: 48, 35
Input: 1000    Output: 1000, 971
Input: 9999    Output: 9984, 9802
</code>```

Worked Through Example

Consider the input of 10, we must run the formula for all numbers from 2-10 (inclusive)

```<code>Num PrimeFacs PrimeFacs^2 SumPrimeFacs^2 Result
2   [2]       [4]         4              -2
3   [3]       [9]         9              -6
4   [2]       [4]         4               0
5   [5]       [25]        25             -20
6   [2, 3]    [4, 9]      13             -7
7   [7]       [49]        49             -42
8   [2]       [4]         4               4
9   [3]       [9]         9               0
10  [2, 5]    [4, 25]     29             -19
</code>```

As you can see the greatest result is 4, which was a result of inputting the value 8 into the formula. That means the output for an input of 10 should be 8, 4

Scoring & Rules

The default rules for inputs and outputs apply: Default for Code Golf: Input/Output methods

The standard loopholes are forbidden: Loopholes that are forbidden by default

Submissions can be functions or full programs

Shortest code in bytes wins

答:
Actually, 21 bytes

```<code>u2x;`;y;*@-`M;M;)@í@E
</code>```

Try it online!

Explanation:

```<code>u2x;`;y;*@-`M;M;)@í@E
u2x;                   push two copies of range(2, n+1) ([2, n])
    `      `M          map:
     ;                   duplicate
      y;                 push two copies of prime divisors
        *                dot product of prime divisors lists (equivalent to sum of squares)
         @-              subtract from n
             ;M;)      duplicate, two copies of max, move one copy to bottom of stack
                 @í    get index of max element
                   @E  get corresponding element from range

</code>```

Body:
Actually, 21 bytes

u2x;`;y;*@-`M;M;)@í@E

Try it online!

Explanation:

u2x;`;y;*@-`M;M;)@í@E
u2x;                   push two copies of range(2, n+1) ([2, n])
    `      `M          map:
     ;                   duplicate
      y;                 push two copies of prime divisors
        *                dot product of prime divisors lists (equivalent to sum of squares)
         @-              subtract from n
             ;M;)      duplicate, two copies of max, move one copy to bottom of stack
                 @í    get index of max element
                   @E  get corresponding element from range


答:
Erlang, 80 bytes

```<code>-module(f).
-export([f/1]).
f(X)->Y=X+(X/3),Z=trunc(Y*(2/3)),[X,trunc(Y),Z,Z+1].
</code>```

To run, save as f.erl, compile and call the function. It will return a list of ints:

```<code>fxk8y@fxk8y:/home/fxk8y/Dokumente/erlang/pcg# erl
Erlang/OTP 18 [erts-7.0] [source] [64-bit] [smp:4:4] [async-    threads:10] [kernel-poll:false]

Eshell V7.0  (abort with ^G)
1> c(f).
{ok,f}
2> f:f(9).
"\t\f\b\t"
3>
</code>```

Note that Erlang automatically converts ints to ASCII chars if you are in the ASCII value range because Erlang doesn't have a char type. Calling the function with 100 gives you the better readable [100,133,88,89].

Ungolfed:

```<code>-module(f).
-export([f/1]).

f(X) ->
  Y = X+(X/3),
  Z = trunc(Y*(2/3)),
  [X, trunc(Y), Z, Z+1].
</code>```

Title: The Nine Pattern

Body:
Erlang, 80 bytes

-module(f).
-export([f/1]).
f(X)->Y=X+(X/3),Z=trunc(Y*(2/3)),[X,trunc(Y),Z,Z+1].

To run, save as f.erl, compile and call the function. It will return a list of ints:

fxk8y@fxk8y:/home/fxk8y/Dokumente/erlang/pcg# erl
Erlang/OTP 18 [erts-7.0] [source] [64-bit] [smp:4:4] [async-    threads:10] [kernel-poll:false]

Eshell V7.0  (abort with ^G)
1> c(f).
{ok,f}
2> f:f(9).
"\t\f\b\t"
3>

Note that Erlang automatically converts ints to ASCII chars if you are in the ASCII value range because Erlang doesn't have a char type. Calling the function with 100 gives you the better readable [100,133,88,89].

Ungolfed:

-module(f).
-export([f/1]).

f(X) ->
  Y = X+(X/3),
  Z = trunc(Y*(2/3)),
  [X, trunc(Y), Z, Z+1].


答:
05AB1E, 15 bytes

Code:

```<code>Ð3/+D·3/D>)1;+ï
</code>```

Uses CP-1252 encoding. Try it online!.

Title: The Nine Pattern

Body:
05AB1E, 15 bytes

Code:

Ð3/+D·3/D>)1;+ï

Uses CP-1252 encoding. Try it online!.


答:
Pyth, <s>17</s> 15 bytes

```<code>_eSttm,-ds^R2{P
</code>```

Test suite.

Title: Greatest Number in a Range When The Sum of Squares of its Prime Factors are Subtracted

Body:
The formula

Take for instance the number 300

The prime factors of 300 are [2, 3, 5] (unique numbers that are
factors of 300 and prime)

Squaring each of those numbers will give
you [4, 9, 25]

Summing that list will give you 4 + 9 + 25 = 38

Finally subtract that sum (38) from your original number 300-38 = 262 (this is the result)

Input

Your input will be a positive integer greater than 2. You must check all numbers from 2 to the input value (inclusive) and find the number that produces the greatest result with the formula above.

Output

Your output will be two numbers separated by a space, comma, newline or whatever you language allows (the separation is necessary to distinguish the two numbers). These can be output to a file, stdout, or whatever your language uses. Your goal is to find the number in the range that produces the maximum output when run through the formula above. The first number displayed should be the starting number (like 300) and the second number should be the output that the formula produced (like 262)

Test Cases

```<code>Input: 3       Output: 2, -2
Input: 10      Output: 8, 4
Input: 50      Output: 48, 35
Input: 1000    Output: 1000, 971
Input: 9999    Output: 9984, 9802
</code>```

Worked Through Example

Consider the input of 10, we must run the formula for all numbers from 2-10 (inclusive)

```<code>Num PrimeFacs PrimeFacs^2 SumPrimeFacs^2 Result
2   [2]       [4]         4              -2
3   [3]       [9]         9              -6
4   [2]       [4]         4               0
5   [5]       [25]        25             -20
6   [2, 3]    [4, 9]      13             -7
7   [7]       [49]        49             -42
8   [2]       [4]         4               4
9   [3]       [9]         9               0
10  [2, 5]    [4, 25]     29             -19
</code>```

As you can see the greatest result is 4, which was a result of inputting the value 8 into the formula. That means the output for an input of 10 should be 8, 4

Scoring & Rules

The default rules for inputs and outputs apply: Default for Code Golf: Input/Output methods

The standard loopholes are forbidden: Loopholes that are forbidden by default

Submissions can be functions or full programs

Shortest code in bytes wins

Body:
Pyth, <s>17</s> 15 bytes

_eSttm,-ds^R2{P

Test suite.


答:
MATL, 18 bytes

```<code>:"@tYfu2^s-]v2#X>w
</code>```

Try it online!

The last case takes too long for the online compiler, but it produces the correct result (it takes about 11 seconds in my computer, running on Matlab):

Explanation

Straightforward application of the described procedure.

```<code>:         % Implicit input n. Range [1 2 ... n]
"         % For each
  @       %   Push that number
  tYfu    %   Duplicate. Prime factors. Unique values
  2^s-    %   Square. Sum of array values. Subtract
]         % End for each
v         % Concatenate stack contents into vertical vector
2#X>      % Max and arg max
w         % Swap. Implicit display
</code>```

Body:
MATL, 18 bytes

:"@tYfu2^s-]v2#X>w

Try it online!

The last case takes too long for the online compiler, but it produces the correct result (it takes about 11 seconds in my computer, running on Matlab):

Explanation

Straightforward application of the described procedure.

:         % Implicit input n. Range [1 2 ... n]
"         % For each
  @       %   Push that number
  tYfu    %   Duplicate. Prime factors. Unique values
  2^s-    %   Square. Sum of array values. Subtract
]         % End for each
v         % Concatenate stack contents into vertical vector
2#X>      % Max and arg max
w         % Swap. Implicit display


答:
><>, <s>63 57</s> 56+2 = <s>65 59</s> 58 bytes

The input numbers are expected to be on the stack at program start, so +2 bytes for the -v flag. Try it online!

```<code></!?lp6$+1g6:
3\0
?\::6g2%*{+}1+:b=
;\~16g-26g2*-c6gf*+n
</code>```

As all unused values in the code field are initialised to 0, it can be used to work out how many of each value is present on the stack by getting the value at [value,6], incrementing it, and putting it back in the code field. The total is then calculated as:

```<code>T = 0 + {for x in 3 to 10, x*([x,6]%2)} - [1,6] - 2*[2,6] + 15*[12,6]
</code>```

Edit: golfed 6 bytes off by restructuring the input and switching the calculation steps around. Previous version:

```<code>:6g1+$6pl0=?\
/-*2g62-g610/
c ;n$\
6:b=?/>::6g2%*{+}1+!
\gf*+3/
</code>```

Edit 2: saved 1 byte, thanks to Sp3000

Title: Golf a golf-scorer

Body:
As a kid, I used to play the card game "golf" a lot. Your challenge, should you choose to accept it, is to calculate the score of a golf hand. Since there are over 9000 variations on this card game1, we will go with the rules I remember playing.

Rules (of the game)

You end a round with 6 cards, and you want as few points as possible.

Jokers are not used.

Aces and 2s are worth -1, and -2 points respectively.

Jacks and Kings are both worth 0 points.

Cards from 3 to 10 are worth face value. However, these are cancelled when you pair them off. For example, a 5 is worth 5 points, but two 5s are worth zero. Three 5s are worth 5 points, (since the first 2 are paired off, but the 3rd is not.) and four 5s are worth 0 (since it makes 2 pairs).

Queens are worth 15 points. Queens cannot be cancelled, e.g. 2 queens are worth 30 points.

Rules (of the challenge)

Input will be an array of integers, or 6 individual integers. Whichever one you prefer. 1 represents an ace, 2-10 represents 2-10, and Jack, Queen, and King represents 11, 12, and 13. Output is the score of the hand according to the rules above. You can safely assume that all inputs are valid, e.g. no number appears more than 4 times, and all numbers are in the range [1, 13]. Input and output can be in any reasonable format.

Test IO:

```<code>[11, 10, 3, 1, 2, 2]    --> 8
[4, 5, 5, 3, 8, 7]      --> 22
[2, 2, 2, 2, 1, 1]      --> -10 (The lowest score possible)
[12, 12, 12, 12, 10, 9] --> 79 (The highest score possible)
[9, 9, 9, 9, 11, 1]     --> -1
[8, 8, 8, 8, 11, 13]    --> 0
[10, 9, 3, 7, 12, 2]    --> 42
[1, 2, 3, 4, 5, 6]      --> 15
[10, 9, 2, 3, 4, 1]     --> 23
[10, 3, 12, 3, 7, 12]   --> 47
</code>```

Shortest answer in bytes wins!

1not really, but there are a lot of variations.

Body:
><>, <s>63 57</s> 56+2 = <s>65 59</s> 58 bytes

The input numbers are expected to be on the stack at program start, so +2 bytes for the -v flag. Try it online!

</!?lp6$+1g6:
3\0
?\::6g2%*{+}1+:b=
;\~16g-26g2*-c6gf*+n

As all unused values in the code field are initialised to 0, it can be used to work out how many of each value is present on the stack by getting the value at [value,6], incrementing it, and putting it back in the code field. The total is then calculated as:

T = 0 + {for x in 3 to 10, x*([x,6]%2)} - [1,6] - 2*[2,6] + 15*[12,6]

Edit: golfed 6 bytes off by restructuring the input and switching the calculation steps around. Previous version:

:6g1+$6pl0=?\
/-*2g62-g610/
c ;n$\
6:b=?/>::6g2%*{+}1+!
\gf*+3/

Edit 2: saved 1 byte, thanks to Sp3000


答:
Clojure, 215 bytes

```<code>(fn j[x](apply max-key second(map(fn[w][w(- w(let[y(reduce +(map #(* % %)(set(flatten((fn f[q](let[c(filter(fn[r](=(mod q r)0))(range 2 q))](if(empty? c)q(map f c))))w)))))](if(= y 0)(* w w)y)))])(range 2(inc x)))))
</code>```

Just follows the rules. Calculates prime factors of each number, put them to square and sum them. After that generate a list of vectors of 2 elements: initial number and its result and find the element with maximum value of second element.

You can see it online here: https://ideone.com/1J9i0y

Body:
Clojure, 215 bytes

(fn j[x](apply max-key second(map(fn[w][w(- w(let[y(reduce +(map #(* % %)(set(flatten((fn f[q](let[c(filter(fn[r](=(mod q r)0))(range 2 q))](if(empty? c)q(map f c))))w)))))](if(= y 0)(* w w)y)))])(range 2(inc x)))))

Just follows the rules. Calculates prime factors of each number, put them to square and sum them. After that generate a list of vectors of 2 elements: initial number and its result and find the element with maximum value of second element.

You can see it online here: https://ideone.com/1J9i0y


答:
MATL, <s>27</s> 26 bytes

```<code>3:10=s2\7M*G12=15*Gt3<*_vs
</code>```

The input is a column array, that is, values are separated by semicolons.

Try it online! or verify all test cases (this adds a loop to take all inputs, and replaces G by 1$0G to push latest input).

Explanation

```<code>3:10=    % Take input implicitly. Compare with range [3 4 ... 10], with broadcast
s        % Sum of each column: how may threes, fours, ... tens there are
2\       % Modulo 2
7M       % Push [3 4 ... 10] again
*        % Element-wise multiply (the sum of this array is the score of 3...10)
G        % Push input again
12=      % Compare with 12, element-wise
15*      % Multiply by 15 (this is the score of 12)
G        % Push input again
t3<      % Duplicate. True for entries 1 or 2
*_       % Multiply and negate (the sum of this array is the score of 1, 2)
v        % Concatenate all stack concents into a vertical array
s        % Sum of array. Implicitly display
</code>```

Title: Golf a golf-scorer

Body:
MATL, <s>27</s> 26 bytes

3:10=s2\7M*G12=15*Gt3<*_vs

The input is a column array, that is, values are separated by semicolons.

Try it online! or verify all test cases (this adds a loop to take all inputs, and replaces G by 1$0G to push latest input).

Explanation

3:10=    % Take input implicitly. Compare with range [3 4 ... 10], with broadcast
s        % Sum of each column: how may threes, fours, ... tens there are
2\       % Modulo 2
7M       % Push [3 4 ... 10] again
*        % Element-wise multiply (the sum of this array is the score of 3...10)
G        % Push input again
12=      % Compare with 12, element-wise
15*      % Multiply by 15 (this is the score of 12)
G        % Push input again
t3<      % Duplicate. True for entries 1 or 2
*_       % Multiply and negate (the sum of this array is the score of 1, 2)
v        % Concatenate all stack concents into a vertical array
s        % Sum of array. Implicitly display


Body:
05AB1E, <s>19</s> <s>17</s> 16 bytes

Code:

L©f€n€O®-®)ø¦{¤R

Explanation:

L                    # make a list of 1..input [1,2,3,4,5,6]
 ©                   # save the list for reuse
  f                  # get primefactors of numbers in list [[],[2],[3],[2],[5],[2,3]]
   €n                # square each factor [[],[4],[9],[4],[25],[4,9]]
     €O              # sum the factors [0,4,9,4,25,13]
       ®-            # subtract from saved list [1,-2,-6,0,-20,-7]
         ®)ø         # zip with saved list [[1,1],[-2,2],[-6,3],[0,4],[-20,5],[-7,6]]
            ¦        # drop the first item (n=1) [[-2,2],[-6,3],[0,4],[-20,5],[-7,6]]
             {       # sort [[-20,5],[-7,6],[-6,3],[-2,2],[0,4]]
              ¤      # get last item [0,4]
               R     # reverse [4,0]

Try it online


答:
Erlang, 46 bytes

Answer inspired by @fxk8y (I couldn't post a comment to his answer)

```<code>F=fun(X)->Z=round(X*4/9),[X,Z*3,Z*2,Z*2+1]end.
</code>```

Also you can see the results with:

```<code>2> io:fwrite("~w~n", [F(9)]).
[9,12,8,9]
ok
</code>```

Title: The Nine Pattern

Body:
Erlang, 46 bytes

Answer inspired by @fxk8y (I couldn't post a comment to his answer)

F=fun(X)->Z=round(X*4/9),[X,Z*3,Z*2,Z*2+1]end.

Also you can see the results with:

2> io:fwrite("~w~n", [F(9)]).
[9,12,8,9]
ok


答:
Brachylog, 48 bytes

```<code>:2:{eI$pd:{:2^.}a+:I--:I.}fF$\hor:0m:Ir.r~m[F:J]
</code>```

Explanation

```<code>Main predicate:

:2:{}fF                     Unify F with the list of all binding for which predicate 1 is
                            true, given [Input, 2] as input.
       $\hor:0m             Retrieve the max of F by diagonalizing it, taking the
                            first row, sorting that row and reversing the sorted row.
               :Ir.         Unify the Output with [I, Max],
                   r~m[F:J] [I, Max] is in F at index J (the index is unimportant)

Predicate 1:

eI                          I is an integer in the range given in Input
  $pd                       Get the list of prime factors of I, with no duplicates
     :{:2^.}a               Apply squaring to each element of that list
             +              Sum the list
              :I-           Subtract I from the sum
                 -          Multiply by -1 (let's call it Result)
                  :I.       Unify the Output with [Result, I]
</code>```

Body:
Brachylog, 48 bytes

:2:{eI$pd:{:2^.}a+:I--:I.}fF$\hor:0m:Ir.r~m[F:J]

Explanation

Main predicate:

:2:{}fF                     Unify F with the list of all binding for which predicate 1 is
                            true, given [Input, 2] as input.
       $\hor:0m             Retrieve the max of F by diagonalizing it, taking the
                            first row, sorting that row and reversing the sorted row.
               :Ir.         Unify the Output with [I, Max],
                   r~m[F:J] [I, Max] is in F at index J (the index is unimportant)

Predicate 1:

eI                          I is an integer in the range given in Input
  $pd                       Get the list of prime factors of I, with no duplicates
     :{:2^.}a               Apply squaring to each element of that list
             +              Sum the list
              :I-           Subtract I from the sum
                 -          Multiply by -1 (let's call it Result)
                  :I.       Unify the Output with [Result, I]


问:
Security by Post-It
As you may know, hackers are everywhere and they want to hack everything. You were asked to make password requirements which will stop any hacker. The problem is, that your boss has heard that paying for LOC is evil and he pays you $1800 - $0.03 * characters inserted per month to make you write simplest thing which possibly could work. So, you have to use small number of characters (hopefully very small), or otherwise forget about cash. Also, your boss doesn't care what language you will use.

The requirements for good passwords are similar to those in mentioned article, except the dictionary based requirements were removed to avoid making solution depend on external files, you don't have to check for letters being rearranged (Hard to understand what it actually means), last rule is removed (What is 3/4?) and it doesn't check old passwords.

The exact requirements after removing certain requirements from linked article are:

have at least 8 character(s)!

not be longer than 12 characters!

have upper and lower case characters!

have no more than 8 upper-case letter(s)!

have no more than 8 lower-case letter(s)!

have at least 2 letter(s)!

have a leading letter!

have at least 1 digit(s)!

not be your username!

not be your username backwards!

not contain your username!

not contain your username backwards!

have no more than 1 pair(s) of repeating characters!

not have 3 occurences of the same character!

not contain carat (^)

not contain space

not contain =

not conatain &

not contain #

not contain ,

not conatain ;

not contain "

not contain >

not contain <

not contain [

not contain |

not contain )

All misspellings on this list were left as is.

```<code>$ ./checkpass
Username: John
Password: L!]E2m69
OK.

$ ./checkpass
Username: John
Password: JohnnhoJ12
Nope.

$ ./checkpass
Username: JOE.smith
Password: JOE!smith123
OK.
</code>```

The shortest code wins money (sent as JPG file). It has to show "Username: " and "Password: " prompts and reply with exact message.

答:
Python 3, 291 bytes/characters

```<code>from re import*
n,p=map(input,["Username: ","Password: "])
c,U,L=lambda x:len(split("[%s]"%x,p)),"A-Z","a-z"
print(["OK.","Nope."][any([8>len(p)>12,2>c(U)>9,2>c(L)>9,3>c(U+L),match(U+L,p),2>c("0-9"),n in p,n[::-1]in p,any(c(x)>3 for x in p),len(findall("(.)\\1",p))>1,c(' ^=&#,;"><[|)')>1])])
</code>```

More nicely formatted and commented:

```<code># import all elements from the regular expression module
from re import *

# Get the two lines of user input (username `n`, password `p`):
n, p = map(input, ["Username: ","Password: "])

# Assign some internally useful shortcuts (uppercase letters `U`, lowercase letters `L`):
# `c(x)` counts the occurrences of pattern `x` in the password `p` plus 1
c, U, L = lambda x: len(split("[%s]" % x, p)), "A-Z", "a-z"

# Print the test result: `"OK."` if the `any(...)` function returned `False`, else `"Nope."`.
# The `any(...)` combines the result of all enclosed checks and returns `True` if at least
# one of the checks failed (returned `True`).
print(["OK.", "Nope."][any([                                # vvv--- CHECKS: ---vvv
                             8>len(p)>12,                   # password length 8-12
                             2>c(U)>9,                      # 1-8 uppercase letters
                             2>c(L)>9,                      # 1-8 lowercase letters
                             3>c(U+L),                      # at least 2 letters
                             match(U+L,p),                  # starts with a letter
                             2>c("0-9"),                    # at least 1 digit
                             n in p,                        # username is not (in) the pw.
                             n[::-1]in p,                   # reversed name not (in) the pw.
                             any(c(x)>3 for x in p),        # at most 3 same characters
                             len(findall("(.)\\1",p))>1,    # at most 1 pair (e.g. "AA")
                             c(' ^=&#,;"><[|)')>1])         # does not contain special char.
                           ])
</code>```

You can find this solution on ideone.com, but the output looks a bit ugly because it does not show the predefined input or even line breaks there. Also, the username-password combination "JOE.smith"-"JOE!smith123" is currently entered as fixed input data.

I added a breakdown of all the checks as debug output though.

Title: Security by Post-It

Body:
Python 3, 291 bytes/characters

from re import*
n,p=map(input,["Username: ","Password: "])
c,U,L=lambda x:len(split("[%s]"%x,p)),"A-Z","a-z"
print(["OK.","Nope."][any([8>len(p)>12,2>c(U)>9,2>c(L)>9,3>c(U+L),match(U+L,p),2>c("0-9"),n in p,n[::-1]in p,any(c(x)>3 for x in p),len(findall("(.)\\1",p))>1,c(' ^=&#,;"><[|)')>1])])

More nicely formatted and commented:

# import all elements from the regular expression module
from re import *

# Get the two lines of user input (username `n`, password `p`):
n, p = map(input, ["Username: ","Password: "])

# Assign some internally useful shortcuts (uppercase letters `U`, lowercase letters `L`):
# `c(x)` counts the occurrences of pattern `x` in the password `p` plus 1
c, U, L = lambda x: len(split("[%s]" % x, p)), "A-Z", "a-z"

# Print the test result: `"OK."` if the `any(...)` function returned `False`, else `"Nope."`.
# The `any(...)` combines the result of all enclosed checks and returns `True` if at least
# one of the checks failed (returned `True`).
print(["OK.", "Nope."][any([                                # vvv--- CHECKS: ---vvv
                             8>len(p)>12,                   # password length 8-12
                             2>c(U)>9,                      # 1-8 uppercase letters
                             2>c(L)>9,                      # 1-8 lowercase letters
                             3>c(U+L),                      # at least 2 letters
                             match(U+L,p),                  # starts with a letter
                             2>c("0-9"),                    # at least 1 digit
                             n in p,                        # username is not (in) the pw.
                             n[::-1]in p,                   # reversed name not (in) the pw.
                             any(c(x)>3 for x in p),        # at most 3 same characters
                             len(findall("(.)\\1",p))>1,    # at most 1 pair (e.g. "AA")
                             c(' ^=&#,;"><[|)')>1])         # does not contain special char.
                           ])

You can find this solution on ideone.com, but the output looks a bit ugly because it does not show the predefined input or even line breaks there. Also, the username-password combination "JOE.smith"-"JOE!smith123" is currently entered as fixed input data.

I added a breakdown of all the checks as debug output though.


Title: The Nine Pattern

Body:
Introduction

I stumbled across this (useless) pattern the other day while I was watching TV.
I named it "the 9 pattern" because the first number to use it was 9.
The gist of it is, you enter a number (let's say x), and then you get back:

x

x + (x / 3) [let's call this y]

two-thirds of y [let's call this z]

z + 1

So, if I put inside this pattern the number 9 as x, this is what would come out:

9 (9)

12 (9 + 9 / 3) [9 over 3 is 3, and 9 + 3 is 12]

8 (12 times two-thirds) [a third of 12 is 4, and 4 * 2 is 8]

9 (8 + 1 is 9)

Challenge

Write me a function (in any programming language) that takes in a number, and outputs an integer array using the pattern.

Somewhat like this psuedo-code:

```<code>function ninePattern(int myInt) returns IntegerArray {
    int iterationA = myInt + (myInt / 3);
    int iterationB = iterationA * (2 / 3);
    int iterationC = iterationB + 1;
    IntegerArray x = [myInt, iterationA, iterationB, iterationC];
    return x;
}
</code>```

Clarifications

Discussions have been arousing in comments regarding the specifications of the question. This section is meant to clarify some of those.

"better to count in bytes than characters"

I picked characters because (for me, at least) it would be easier to judge. Of course, I can't change that now. (lots of answers are already posted)

"rounding"

Rounding follows this rhyme:

If it's 5 or more, raise the score

  If it's 4 or less, let it rest

Simply, put, if it is something like 4.7 or 3.85, round them to 5 and 4 respectively.

Examples

```<code>Input => Result
9 => [9, 12, 8, 9]
8 => [8, 11, 7, 8]
6 => [6, 8, 5, 6]
23 => [23, 31, 21, 22]
159 => [159, 212, 141, 142]
</code>```

If, however, the numbers are something like 2.3 or 10.435446, round them to 2 and 10 respectively.

"language support"

You are free to not use functions and/or arrays IF AND ONLY IF the language of your choice does not support them.  If it does (even if it will increase your characters count), you must use them.

Body:
MarioLANG, <s>659</s> <s>621</s> <s>591</s> <s>582</s> <s>556</s> <s>543</s> <s>516</s> <s>458</s> <s>418</s> <s>401</s> <s>352</s> <s>308</s> 369 bytes

rounding is quite expensive :/

<a href="http://mariolang.tryitonline.net/#code=Oz4-WyFbKCBbKCBbKCBbKCBbKCBbPCgoWyEpKSkhKygoKC08PiggPigoKwo6Ij09Iz09PT09PT09PT09PT09PT0iPT09Iz09ICM9PT09PSIiWyAiPT0KKSggIC1bISk-PlshWykgIFspWzwoIT4pWzwpKSA-KSkpIFshIS1bISgoCiAoICApIiM9Ij09Iz09PT09PT0iPSM9PT0iPTw9Ij09PT09IyM9PSM9PTwKICsgICs-KSApLSs8PispWyEpKyEgKykpIVstWyk-WyBbKFstWyFbPDw6CiArICApLSsgKSg9IiI9PT0jPT0jICA9PSM9PT0pIj09PT09PT0jPT09PT0KICsgID4hPikhPiAgISgtIDwgITorOikpPCAgKSkhKCgrKykpKTwgCiApICAiIyI9Iz09PSM9PT0iID09PT09PSIgPT09Iz09PT09PT0iCiAhCj0jPT09PT09PT09PT09PT09PT09PT09PT09&input=MjM" rel="nofollow">Try it online

;>>[![( [( [( [( [( [<(([!)))!+(((-<>( >((+
:"==#================"===#== #=====""[ "==
)(  -[!)>>[![)  [)[<(!>)[<)) >))) [!!-[!((
 (  )"#="==#======="=#==="=<="=====##==#==<
 +  +>) )-+<>+)[!)+! +))![-[)>[ [([-[![<<:
 +  )-+ )(=""===#==#  ==#===)"=======#=====
 +  >!>)!>  !(- < !:+:))<  ))!((++)))<
 )  "#"=#===#===" ======" ===#======="
 !
=#========================

Well this was more fun than expected, this is probably not optimal but I guess i'm getting there.

Explanation time:

(for the 352 bytes version)

first we get the argument and print it :

;
:

simple enough

we then move to the bulk of the program : the division input / 3

;>>[![              [( [( [<result
:"==#======================"======
)   -[!)>>[![        [<((((!
)   )"#="==#=========="====#
+(  +>) )  +>(+)[!)+))!
+(  )-+ )  -"====#====#
+   >!>)!  >! -  <
    "#"=#  "#===="
 !
=#

which is a slightly modified conversion of the brainfuck division

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

which take for input

n 0 d 0 0

and give you back

0 n d-n%d n%d n/d

once we got the division we use it to get the sum of n and n/d and print it

;>>[![              [( [( [<    !+(((-<
:"==#======================"===)#====="
)   -[!)>>[![        [<((((!    >))) [!(((
)   )"#="==#=========="====#   ="=====#==:
+(  +>) )  +>(+)[!)+))!
+(  )-+ )  -"====#====#
+   >!>)!  >! -  <
    "#"=#  "#===="
 !
=#

we then need to do another division : ( 2 * ( n + n / d ) ) / 3

so we get ( 2 * ( n + n / d )

;>>[![              [( [( [<    !+(((-<
:"==#======================"===)#====="
)   -[!)>>[![        [<((((!    >))) [!(((
)   )"#="==#=========="====#   ="=====#==:
+(  +>) )  +>(+)[!)+))! 2*2n/d>[   -[![  <
+(  )-+ )  -"====#====# ======"======#====
+   >!>)!  >! -  <            !((++))<
    "#"=#  "#===="            #======"
 !
=#

and put it with 3 back into the division

;>>[![              [( [( [<    !+(((-<
:"==#======================"===)#====="
)   -[!)>>[![        [<((((!    >))) [!(((
)   )"#="==#=========="====#   ="=====#==:
+(  +>) )  +>(+)[!)+))!      )>[   -[![  <
+(  )-+ )  -"====#====#      )"======#====
+   >!>)!  >! -  <       +++))!((++))<
    "#"=#  "#====" ===========#======"
 !
=#=================

at that point everything explose, mario is stuck in an infinite loop doing division on bigger and bigger number, forever.

and to fix that we need a way to diferenciate between the first and the second division, it end up that, oh joy, we do have a way

;>>[![              [( [( [<([!)!+(((-<
:"==#======================"==#)#====="
)   -[!)>>[![        [<((((!))< >))) [!(((
)   )"#="==#=========="====#)="="=====#==:
+(  +>) )  +>(+)[!)+))!!:+:)))>[   -[![  <
+(  )-+ )  -"====#====#======)"======#====
+   >!>)!  >! -  <       +++))!((++))<
    "#"=#  "#====" ===========#======"
 !
=#=================

basically we look if the x in

x 0 n d-n%d n%d n/d

is 0, if it is it mean we are on the first division

else we are on the second division, and we just print the result of the division, add 1 then print it again

and voilà easy as pie.


答:
Java 8 lambda, <s>109</s> <s>81</s> <s>79</s> 75 characters

Because... you know... even Java can be golfed...

```<code>a->{int b=(int)(.5+a*4./3),c=(int)(.5+b*2./3);return new int[]{a,b,c,++c};}
</code>```

Lambda ungolfed into class:

```<code>class C {
   static int[] a(int a) {
        int b = (int) (.5 + a * 4. / 3),
            c = (int) (.5 + b * 2. / 3);
        return new int[]{a, b, c, ++c};
    }
}
</code>```

<s>I assume I'm allowed to use longs as they are also an integer type.
Sadly one needs to correctly round integers and thus a "short" cast doesn't work. By using longs we don't need to cast the rounding results back to ints.</s>

Update

Using the nice little + 0.5 and casting afterwards trick we keep the correct rounding and save 2 chars!

Also this trick doesn't require the use of long any longer thus we can switch back to ints shaving of 4 more chars.

Title: The Nine Pattern

Body:
Java 8 lambda, <s>109</s> <s>81</s> <s>79</s> 75 characters

Because... you know... even Java can be golfed...

a->{int b=(int)(.5+a*4./3),c=(int)(.5+b*2./3);return new int[]{a,b,c,++c};}

Lambda ungolfed into class:

class C {
   static int[] a(int a) {
        int b = (int) (.5 + a * 4. / 3),
            c = (int) (.5 + b * 2. / 3);
        return new int[]{a, b, c, ++c};
    }
}

<s>I assume I'm allowed to use longs as they are also an integer type.
Sadly one needs to correctly round integers and thus a "short" cast doesn't work. By using longs we don't need to cast the rounding results back to ints.</s>

Update

Using the nice little + 0.5 and casting afterwards trick we keep the correct rounding and save 2 chars!

Also this trick doesn't require the use of long any longer thus we can switch back to ints shaving of 4 more chars.


问:
Showcase of Languages

Notes

This thread is open and unlocked only because the community decided to make an exception. Please do not use this question as evidence that you can ask similar questions here. Please do not create additional showcase questions.

This is no longer a popularity-contest, nor are snippet lengths limited by the vote tally. If you know this thread from before, please make sure you familiarize yourself with the changes.

This thread is dedicated to showing off interesting, useful, obscure, and/or unique features your favorite programming languages have to offer. This is neither a challenge nor a competition, but a collaboration effort to showcase as many programming languages as possible as well as possible.

How this works

All answers should include the name of the programming language at the top of the post, prefixed by a #.

Answers may contain one (and only one) factoid, i.e., a couple of sentences without code that describe the language.

Aside from the factoid, answers should consist of snippets of code, which can (but don't have to be) programs or functions.

The snippets do not need to be related. In fact, snippets that are too related may be redundant.

Since this is not a contest, all programming languages are welcome, whenever they were created.

Answers that contain more than a handful of code snippets should use a Stack Snippet to collapse everything except the factoid and one of the snippets.

Whenever possible, there should be only one answer per programming language. This is a community wiki, so feel free to add snippets to any answer, even if you haven't created it yourself. There is a Stack Snippet for compressing posts, which should mitigate the effect of the 30,000 character limit.

Answers that predate these guidelines should be edited. Please help updating them as needed.

Current answers, sorted alphabetically by language name

$.ajax({type:"GET",url:"https://api.stackexchange.com/2.2/questions/44680/answers?site=codegolf&filter=withbody",success:function(data){for(var i=0;i<data.items.length;i++){var temp=document.createElement('p');temp.innerHTML = data.items[i].body.split("\n")[0];$('#list').append('
' + temp.innerText || temp.textContent + '');}}})```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><base href="http://codegolf.stackexchange.com"><ul id="list"></ul></code>```

答:
Unipants' Golfing Language

Factoid

UGL only has 16 operations, a stack, registers, ifs and whiles to do things. But even if these supplies are to spare, anything may be possible if you do things smart enough... or not? ;-)

Length 5 snippet

```<code>IlOI:
</code>```

Try it online!

This is the cat program. As you see, it is a translation of the brainfuck program ,[.,].

I captures one character, so it is the same as , in bf. O prints one character, so it is the same as . in bf. And l and : enclose a while loop, that works the same as [ and ] in bf (while the top of stack is non zero).

Length 2 snippet

```<code>io
</code>```

Try it online!

This program reads and writes an integer. And guess it, it can be any length. i is greedy, meaning it will catch as long an integer as possible.

Length 1 snippet

```<code>s
</code>```

Try it online!

This program sets the current register number to zero. First, let me show you an excerpt of the README for registers:

Registers

r - load the value in current register

R - save the value in current register

s - set current register number to top of stack

If the stack is empty, the current register number is set to zero.

Title: Showcase of Languages

Body:
Unipants' Golfing Language

Factoid

UGL only has 16 operations, a stack, registers, ifs and whiles to do things. But even if these supplies are to spare, anything may be possible if you do things smart enough... or not? ;-)

Length 5 snippet

IlOI:

Try it online!

This is the cat program. As you see, it is a translation of the brainfuck program ,[.,].

I captures one character, so it is the same as , in bf. O prints one character, so it is the same as . in bf. And l and : enclose a while loop, that works the same as [ and ] in bf (while the top of stack is non zero).

Length 2 snippet

io

Try it online!

This program reads and writes an integer. And guess it, it can be any length. i is greedy, meaning it will catch as long an integer as possible.

Length 1 snippet

s

Try it online!

This program sets the current register number to zero. First, let me show you an excerpt of the README for registers:

Registers

r - load the value in current register

R - save the value in current register

s - set current register number to top of stack

If the stack is empty, the current register number is set to zero.


答:
JSFuck

Length 6

```<code>+[![]]
</code>```

Since ![] is false, [![]].toString() is "false", which isn't a valid number. Therefore, when converting to number, it returns NaN.

I decide to make it here because it's the first time we can create an uppercase letter, and uppercase letter usually take a lot of code to generate.

Length 5

```<code>+!+[]
</code>```

As mentioned before (in the length 4 section), !+[] produces true. Also, as mentioned before (in the length 1 section), + can cast to number.

Therefore, this code casts true to number, which is 1.

This snippet can be chained indefinitely to produce any number you want.

For example, 2 would be +!+[]+!+[], and 3 would be +!+[]+!+[]+!+[].

As mentioned before (in the length 4 section), +!![] is also valid.

Length 4

```<code>!+[]
</code>```

The operation ! casts to boolean.

The number 0, the empty string "", the undefined, and the NaN are all treated as false.

Other objects are treated as true.

Unlike Python, the empty array [] and the empty object literal {} are treated as true.

Therefore, this is the shortest snippet to produce true. It is equivalent to !0.

!![] would also work.

Length 3

```<code>+[]
</code>```

As mentioned before, + casts to integer. In this case, it would be evaluated to 0.

However, also as mentioned before, + can join two arrays to form a string.

Therefore, +[]+[] is really 0+[] which would produce "0".

Length 2

```<code>++
</code>```

There are really only 36 length-2 snippets.

Out of the 36 snippets, I chose this one.

This is the shortest way to add 1 to a number.

This function is very strange.

For example, v=1; ++v works, but ++1 does not.

For example, v=[]; ++v also works (empty array [] is implicitly cast to 0), but ++[] does not.

To make it work in JSFuck, you would have to type ++[[]][+[]] instead.

[[]][+[]] is really [[]][0], which is an empty array [].

Why ++[[]][+[]] works but not ++[] is yeond me.

Length 1

```<code>+
</code>```

+ can convert a string to a number, as well as adding two arrays together to form a string. For example, +"0" would result in the number 0, and [1]+[0] will result in the string "10".

Factoid

All JSFuck programs are valid Javascript programs. However, JSFuck aims to use only 6 operators to do everything: +![](). Also, its name is derived from JS (javascript) and Brainfuck. Brainfuck only uses 8 operators.

Title: Showcase of Languages

Body:
Notes

This thread is open and unlocked only because the community decided to make an exception. Please do not use this question as evidence that you can ask similar questions here. Please do not create additional showcase questions.

This is no longer a popularity-contest, nor are snippet lengths limited by the vote tally. If you know this thread from before, please make sure you familiarize yourself with the changes.

This thread is dedicated to showing off interesting, useful, obscure, and/or unique features your favorite programming languages have to offer. This is neither a challenge nor a competition, but a collaboration effort to showcase as many programming languages as possible as well as possible.

How this works

All answers should include the name of the programming language at the top of the post, prefixed by a #.

Answers may contain one (and only one) factoid, i.e., a couple of sentences without code that describe the language.

Aside from the factoid, answers should consist of snippets of code, which can (but don't have to be) programs or functions.

The snippets do not need to be related. In fact, snippets that are too related may be redundant.

Since this is not a contest, all programming languages are welcome, whenever they were created.

Answers that contain more than a handful of code snippets should use a Stack Snippet to collapse everything except the factoid and one of the snippets.

Whenever possible, there should be only one answer per programming language. This is a community wiki, so feel free to add snippets to any answer, even if you haven't created it yourself. There is a Stack Snippet for compressing posts, which should mitigate the effect of the 30,000 character limit.

Answers that predate these guidelines should be edited. Please help updating them as needed.

Current answers, sorted alphabetically by language name

$.ajax({type:"GET",url:"https://api.stackexchange.com/2.2/questions/44680/answers?site=codegolf&filter=withbody",success:function(data){for(var i=0;i<data.items.length;i++){var temp=document.createElement('p');temp.innerHTML = data.items[i].body.split("\n")[0];$('#list').append('
' + temp.innerText || temp.textContent + '');}}})```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><base href="http://codegolf.stackexchange.com"><ul id="list"></ul></code>```

Body:
JSFuck

Length 6

+[![]]

Since ![] is false, [![]].toString() is "false", which isn't a valid number. Therefore, when converting to number, it returns NaN.

I decide to make it here because it's the first time we can create an uppercase letter, and uppercase letter usually take a lot of code to generate.

Length 5

+!+[]

As mentioned before (in the length 4 section), !+[] produces true. Also, as mentioned before (in the length 1 section), + can cast to number.

Therefore, this code casts true to number, which is 1.

This snippet can be chained indefinitely to produce any number you want.

For example, 2 would be +!+[]+!+[], and 3 would be +!+[]+!+[]+!+[].

As mentioned before (in the length 4 section), +!![] is also valid.

Length 4

!+[]

The operation ! casts to boolean.

The number 0, the empty string "", the undefined, and the NaN are all treated as false.

Other objects are treated as true.

Unlike Python, the empty array [] and the empty object literal {} are treated as true.

Therefore, this is the shortest snippet to produce true. It is equivalent to !0.

!![] would also work.

Length 3

+[]

As mentioned before, + casts to integer. In this case, it would be evaluated to 0.

However, also as mentioned before, + can join two arrays to form a string.

Therefore, +[]+[] is really 0+[] which would produce "0".

Length 2

++

There are really only 36 length-2 snippets.

Out of the 36 snippets, I chose this one.

This is the shortest way to add 1 to a number.

This function is very strange.

For example, v=1; ++v works, but ++1 does not.

For example, v=[]; ++v also works (empty array [] is implicitly cast to 0), but ++[] does not.

To make it work in JSFuck, you would have to type ++[[]][+[]] instead.

[[]][+[]] is really [[]][0], which is an empty array [].

Why ++[[]][+[]] works but not ++[] is yeond me.

Length 1

+

+ can convert a string to a number, as well as adding two arrays together to form a string. For example, +"0" would result in the number 0, and [1]+[0] will result in the string "10".

Factoid

All JSFuck programs are valid Javascript programs. However, JSFuck aims to use only 6 operators to do everything: +![](). Also, its name is derived from JS (javascript) and Brainfuck. Brainfuck only uses 8 operators.


答:
Java 8 lambda, <s>247</s> <s>239</s> <s>233</s> <s>225</s> <s>224</s> <s>219</s> <s>198</s> 161 characters

I thought that must be possible in under 300 chars because... you know... Java!

And it is indeed possible even in under 200 chars!

```<code>m->{int n=1,u,f,F[],g,G=g=1<<31;for(;++n<=m;){u=n;F=new int[m+1];for(f=1;++f<=u;)u/=u%f<1?(F[f]=f--):1;f=0;for(int p:F)f+=p*p;g=n-f>g?(G=n)-f:g;}return G+","+g;}
</code>```

<s>I don't know whether this use of imports is legit but I assume, that it should be okay.</s> Here is the lambda ungolfed into a class:

```<code>public class Q80507 {
    static String greatestAfterReduction(int maxNumber) {
        int number = 1, upper, factor, primeFactors[], greatestResult, greatestNumber = greatestResult = 1 << 31; // <-- Integer.MIN_VALUE;
        for (;++number <= maxNumber;) {
            // get unique primefactors
            upper = number;
            primeFactors = new int[maxNumber + 1];
            for (factor = 1; ++factor <= upper;)
                upper /= upper % factor < 1 ? (primeFactors[factor] = factor--) : 1;

            factor = 0;
            for (int prime : primeFactors)
                factor += prime * prime;

            greatestResult = number - factor > greatestResult ? (greatestNumber = number) - factor : greatestResult;
        }
        return greatestNumber + "," + greatestResult;
    }
}
</code>```

The primefactor-finding is based on this answer. The code uses the functionality of sets as they only save each value once, thus I don't have to care about added duplicates later on. The rest of the code is pretty straight forward, just following the question.

Updates

Removed the newline from the output.

Thanks to @ogregoire for golfing the Integer.MIN_VALUE to 1<<31!

After looking on the code again I found some more places where things could been golfed.

Thanks to @Blue for the ==0 to <1 trick!

Removed some leftover whitespace. Also for separation only one char is needed so no need to waste one char.

Thanks again to @ogregoire for pointing out that I can return the value instead of printing it and putting together the declarations! This saved a lot!

Found out I can use a ternary instead of the second if to save one more char.

Thanks to @AstronDan for the awesome usage of an array which saves the import. That also gave me the possibility to shorten the first if into a ternary.

Body:
The formula

Take for instance the number 300

The prime factors of 300 are [2, 3, 5] (unique numbers that are
factors of 300 and prime)

Squaring each of those numbers will give
you [4, 9, 25]

Summing that list will give you 4 + 9 + 25 = 38

Finally subtract that sum (38) from your original number 300-38 = 262 (this is the result)

Input

Your input will be a positive integer greater than 2. You must check all numbers from 2 to the input value (inclusive) and find the number that produces the greatest result with the formula above.

Output

Your output will be two numbers separated by a space, comma, newline or whatever you language allows (the separation is necessary to distinguish the two numbers). These can be output to a file, stdout, or whatever your language uses. Your goal is to find the number in the range that produces the maximum output when run through the formula above. The first number displayed should be the starting number (like 300) and the second number should be the output that the formula produced (like 262)

Test Cases

```<code>Input: 3       Output: 2, -2
Input: 10      Output: 8, 4
Input: 50      Output: 48, 35
Input: 1000    Output: 1000, 971
Input: 9999    Output: 9984, 9802
</code>```

Worked Through Example

Consider the input of 10, we must run the formula for all numbers from 2-10 (inclusive)

```<code>Num PrimeFacs PrimeFacs^2 SumPrimeFacs^2 Result
2   [2]       [4]         4              -2
3   [3]       [9]         9              -6
4   [2]       [4]         4               0
5   [5]       [25]        25             -20
6   [2, 3]    [4, 9]      13             -7
7   [7]       [49]        49             -42
8   [2]       [4]         4               4
9   [3]       [9]         9               0
10  [2, 5]    [4, 25]     29             -19
</code>```

As you can see the greatest result is 4, which was a result of inputting the value 8 into the formula. That means the output for an input of 10 should be 8, 4

Scoring & Rules

The default rules for inputs and outputs apply: Default for Code Golf: Input/Output methods

The standard loopholes are forbidden: Loopholes that are forbidden by default

Submissions can be functions or full programs

Shortest code in bytes wins

Body:
Java 8 lambda, <s>247</s> <s>239</s> <s>233</s> <s>225</s> <s>224</s> <s>219</s> <s>198</s> 161 characters

I thought that must be possible in under 300 chars because... you know... Java!

And it is indeed possible even in under 200 chars!

m->{int n=1,u,f,F[],g,G=g=1<<31;for(;++n<=m;){u=n;F=new int[m+1];for(f=1;++f<=u;)u/=u%f<1?(F[f]=f--):1;f=0;for(int p:F)f+=p*p;g=n-f>g?(G=n)-f:g;}return G+","+g;}

<s>I don't know whether this use of imports is legit but I assume, that it should be okay.</s> Here is the lambda ungolfed into a class:

public class Q80507 {
    static String greatestAfterReduction(int maxNumber) {
        int number = 1, upper, factor, primeFactors[], greatestResult, greatestNumber = greatestResult = 1 << 31; // <-- Integer.MIN_VALUE;
        for (;++number <= maxNumber;) {
            // get unique primefactors
            upper = number;
            primeFactors = new int[maxNumber + 1];
            for (factor = 1; ++factor <= upper;)
                upper /= upper % factor < 1 ? (primeFactors[factor] = factor--) : 1;

            factor = 0;
            for (int prime : primeFactors)
                factor += prime * prime;

            greatestResult = number - factor > greatestResult ? (greatestNumber = number) - factor : greatestResult;
        }
        return greatestNumber + "," + greatestResult;
    }
}

The primefactor-finding is based on this answer. The code uses the functionality of sets as they only save each value once, thus I don't have to care about added duplicates later on. The rest of the code is pretty straight forward, just following the question.

Updates

Removed the newline from the output.

Thanks to @ogregoire for golfing the Integer.MIN_VALUE to 1<<31!

After looking on the code again I found some more places where things could been golfed.

Thanks to @Blue for the ==0 to <1 trick!

Removed some leftover whitespace. Also for separation only one char is needed so no need to waste one char.

Thanks again to @ogregoire for pointing out that I can return the value instead of printing it and putting together the declarations! This saved a lot!

Found out I can use a ternary instead of the second if to save one more char.

Thanks to @AstronDan for the awesome usage of an array which saves the import. That also gave me the possibility to shorten the first if into a ternary.


问:
Implement a Truth-Machine
A truth-machine (credits goes to this guy for coming up with it) is a very simple program designed to demonstrate the I/O and control flow of a language. Here's what a truth-machine does:

Gets a number (either 0 or 1) from STDIN.

If that number is 0, print out 0 and terminate.

If that number is 1, print out 1 forever.

Challenge

Write a truth-machine as described above in your language of choice. The truth-machine must be a full program that follows these rules:

take input from STDIN or an acceptable alternative

If your language cannot take input from STDIN, it may take input from a hardcoded variable or suitable equivalent in the program

must output to STDOUT or an acceptable alternative

If your language is incapable of outputting the characters 0 or 1, byte or unary I/O is acceptable.

when the input is 1, it must continually print 1s and only stop if the program is killed or runs out of memory

the output must only be either a 0 followed by either one or no newline or space, or infinite 1s with each 1 followed by either one or no newline or space. 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). Your usage of newlines or spaces must be consistent: for example, if you choose to output 1 with a newline after it all 1s must have a newline after them.

if and only if your language cannot possibly terminate on an input of 0 it is acceptable for the code to enter an infinite loop in which nothing is outputted.

Since this is a catalog, languages created after this challenge are allowed to compete. 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. 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).

Catalog

The Stack Snippet at the bottom of this post generates the catalog 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

```

答:
Tellurium, 11 bytes

```<code>I?1|[i|^;]^
</code>```

This program asks for input and converts it to an integer (I). After that, it checks if the input is 1. If it's 1, output 1 forever ([i|^;). If it's 0, output 0.

Title: Implement a Truth-Machine

Body:
Tellurium, 11 bytes

I?1|[i|^;]^

This program asks for input and converts it to an integer (I). After that, it checks if the input is 1. If it's 1, output 1 forever ([i|^;). If it's 0, output 0.


问:
Real-time string matching
Task

The task is to golf a real-time exact string matching algorithm of your choice.

Input

Two lines of text supplied on standard input, separated by a new line. The first line contains the "pattern" and will simply be an ASCII string drawn from the letters a-z.

The second line contains the longer "text" and will also simply be an ASCII string drawn from the letters a-z.

Output

A list of indices of where the exact matches occur.  You should output the position of the start of each match that occurs.

Specification

Your algorithm can spend linear time preprocessing the pattern. It must then read the text from left to right and take constant time for every single character in the text and output any new match as soon as it occurs.  Matches can of course overlap each other.

Algorithm

There are many real-time exact matching algorithms. One is mentioned on the wiki for KMP for example. You can use any one you like but you must always output the right answer.

I will keep a per language leader table so that those who prefer popular languages can also win in their own way.  Please explain which algorithm you have implemented.

Real-time

It seems there has been a lot of confusion over what real-time means. It doesn't simply mean linear time. So standard KMP is not real-time. The link in the question explicitly points to a part of the wiki page for KMP about a real-time variant of KMP. Neither is Boyer-Moore-Galil real-time.  This cstheory question/answer discusses the issue or one can just google "real-time exact matching" or similar terms.

答:
Q, 146 Bytes

```<code>W:S:u:"";n:0;p:{$[n<#x;0;x~(#x)#W;#x;0]};f:{{|/p'x}'((1_)\x#W),\:/:u};F:{S::x 1;W::*x;n::#W;u::?W;T:(f'!1+n),\:0;(&n=T\[0;u?S])-n-1}
</code>```

Test

```F"
 ABCDABD
 ABCdABCDABgABCDABCDABDEABCDABzABCDABCDABDE"```

generates 15 and 34

Notes

Not restricted to alphabet (support any ascii char, and is case-sensitive).

Not uses any of the specific operations defined by Q over strings -> works on strings as sequences (ops match, length, etc.)

Minimizes transition table joining all characters not in pattern as one unique character-class.

I can squeeze code a little. It's a first attempt to validate solution strategy

Visit any character of text exactly once, and for each input character there is a unique jump. So I assume that search fits as 'real time'

Table construction al state i and char c search for longest substring that ends at i and after appending c is a prefix of S. Construction is not optimized, so i don't know if its valid

Input format doesn't fit well with language. Passing two string arguments will save 16 Bytes

Explanation

global W represents pattern and S corresponds to text to search

x:1_"\n "\:x  weird code to cope with input requirements (Q requires thtat multiline strings has non-first lines indented, so it must discard added space in front of every non-first line)

n::#W calculates W lenght and save as global n

u::?W calculates unique chars in W, and save as global u

u?S  generates the characted-class for each char of S

Construct a transition table T with one row per unique character in W (plus one extra), and a column for each index in W (plus one extra). Extra row correspond to initial state, and extra column collects any char in S but not in W. This strategy minimizes table size

p:{$[n<#x;0;x~(#x)#W;#x;0]} is the function that search longest prefix

f:{{|/p'x}'((1_)\x#W),\:/:u} is the function that calculates a row x of T

```<code>T:(f'!1+n),\:0 applies f repeteadly to calculate each row, and adds value 0 to each row
</code>```

Search text using transition table. T\[0;u?S] iterates over 0 (initial state) and each of the character class of S, using as a new value the value at transitition table T[state][charClass]. Final states has value n, so we look for that value in the sequence of states and returns it adjusted (to indicate initial instead of final position of each match)

Title: Real-time string matching

Body:
Q, 146 Bytes

W:S:u:"";n:0;p:{$[n<#x;0;x~(#x)#W;#x;0]};f:{{|/p'x}'((1_)\x#W),\:/:u};F:{S::x 1;W::*x;n::#W;u::?W;T:(f'!1+n),\:0;(&n=T\[0;u?S])-n-1}

Test

F"
 ABCDABD
 ABCdABCDABgABCDABCDABDEABCDABzABCDABCDABDE"

generates 15 and 34

Notes

Not restricted to alphabet (support any ascii char, and is case-sensitive).

Not uses any of the specific operations defined by Q over strings -> works on strings as sequences (ops match, length, etc.)

Minimizes transition table joining all characters not in pattern as one unique character-class.

I can squeeze code a little. It's a first attempt to validate solution strategy

Visit any character of text exactly once, and for each input character there is a unique jump. So I assume that search fits as 'real time'

Table construction al state i and char c search for longest substring that ends at i and after appending c is a prefix of S. Construction is not optimized, so i don't know if its valid

Input format doesn't fit well with language. Passing two string arguments will save 16 Bytes

Explanation

global W represents pattern and S corresponds to text to search

x:1_"\n "\:x  weird code to cope with input requirements (Q requires thtat multiline strings has non-first lines indented, so it must discard added space in front of every non-first line)

n::#W calculates W lenght and save as global n

u::?W calculates unique chars in W, and save as global u

u?S  generates the characted-class for each char of S

Construct a transition table T with one row per unique character in W (plus one extra), and a column for each index in W (plus one extra). Extra row correspond to initial state, and extra column collects any char in S but not in W. This strategy minimizes table size

p:{$[n<#x;0;x~(#x)#W;#x;0]} is the function that search longest prefix

f:{{|/p'x}'((1_)\x#W),\:/:u} is the function that calculates a row x of T

T:(f'!1+n),\:0 applies f repeteadly to calculate each row, and adds value 0 to each row

Search text using transition table. T\[0;u?S] iterates over 0 (initial state) and each of the character class of S, using as a new value the value at transitition table T[state][charClass]. Final states has value n, so we look for that value in the sequence of states and returns it adjusted (to indicate initial instead of final position of each match)


答:
Java, <s>56</s> 80 Bytes

As some users pointed out, this solution (as some others in java) does not round data properly. So now I'm presenting slightly longer solution which should return correct result

```<code>int[]h(int a){int[]b={a,Math.round(a+a/3f),a=Math.round(a*8f/9),++a};return b;}
</code>```

or 60  bytes lamda version

```<code>a->new int[]{a,Math.round(a+a/3f),a=Math.round(a*8f/9),++a}
</code>```

<s>
Golfed version

```<code>int[]g(int a){int[]b={a,a+a/3,a*8/9,a*8/9+1};return b;}
</code>```

and ungolfed

```<code>int[] g(int a) {
        int[] b = { a, a + a / 3, a * 8 / 9, a * 8 / 9 + 1 };
        return b;
    }
</code>```

or 36 bytes defined as lambda

```<code>a->new int[]{a,a+a/3,a*8/9,a*8/9+1}
</code>```

</s>

Title: The Nine Pattern

Body:
Java, <s>56</s> 80 Bytes

As some users pointed out, this solution (as some others in java) does not round data properly. So now I'm presenting slightly longer solution which should return correct result

int[]h(int a){int[]b={a,Math.round(a+a/3f),a=Math.round(a*8f/9),++a};return b;}

or 60  bytes lamda version

a->new int[]{a,Math.round(a+a/3f),a=Math.round(a*8f/9),++a}

<s>
Golfed version

int[]g(int a){int[]b={a,a+a/3,a*8/9,a*8/9+1};return b;}

and ungolfed

int[] g(int a) {
        int[] b = { a, a + a / 3, a * 8 / 9, a * 8 / 9 + 1 };
        return b;
    }

or 36 bytes defined as lambda

a->new int[]{a,a+a/3,a*8/9,a*8/9+1}

</s>


Body:
CJam, 32 bytes

ri({))_mf_|2f#:+-}/]_:e>_@#))\]p

Try it online!


答:
Pyke, 11 bytes

```<code>D}[}3/bD)[h
</code>```

Try it here!

```<code>            - implicit input()
D           - a,b = ^
 }          - b*=2
  [}3/bD)   - macro:
   }        -   tos*=2
    3/      -   tos/=3
      b     -   tos = round(tos)
       D    -   old_tos = tos = tos
            - macro
         [  - macro
          h - d +=1
</code>```

Title: The Nine Pattern

Body:
Pyke, 11 bytes

D}[}3/bD)[h

Try it here!

            - implicit input()
D           - a,b = ^
 }          - b*=2
  [}3/bD)   - macro:
   }        -   tos*=2
    3/      -   tos/=3
      b     -   tos = round(tos)
       D    -   old_tos = tos = tos
            - macro
         [  - macro
          h - d +=1


问:
Don't google "google"
We all know that if you google the word "google" it will break the internet.

Your task is to create a function that accepts one string and returns its length, in the fewest possible Unicode characters.

However, if the given string is google (lowercase), it will cause an error.

For example, g('bing') will return 4 but g('google') will cause an error.

Please provide an example of usage, and the error if possible.

答:
Tellurium, 13 bytes

This language is newer than the question, so non-competing I guess.

```<code>i?google|d]L^
</code>```

This program gets input using i, and checks if the input is "google". If it is, it tries dividing "google" by zero (d) well, that doesn't work (duh) so it throws an error.

If the input isn't google, it outputs the length of the selected cell's value (which is the input) using L^.

Title: Don't google "google"

Body:
Tellurium, 13 bytes

This language is newer than the question, so non-competing I guess.

i?google|d]L^

This program gets input using i, and checks if the input is "google". If it is, it tries dividing "google" by zero (d) well, that doesn't work (duh) so it throws an error.

If the input isn't google, it outputs the length of the selected cell's value (which is the input) using L^.


答:
Mathcad, [tbd] bytes

Mathcad codegolf byte equivalance is yet to be determined.   Taking a keyboard count as a rough equivalent, the solution is approx 40 bytes.

Title: The Nine Pattern


答:
Scratch

Factoid: Scratch has a great appeal to younger audiences, with the large majority of new accounts being from 10 to 16 years old.

1 block

The say block takes what is in the text space and outputs it as a text bubble.

2 blocks

The when green flag clicked block is essential for most programs.  The stop [all/this script/other scripts in sprite] block does exactly what it says, but it isn't used much in optimized scripts.

Title: Showcase of Languages


答:
Java, 64 bytes

```<code>int[]f(int i){return new int[]{i,i+=i/3+0.5,i-=i/3-0.5,i+=1.5};}
</code>```

Notes

This has the required rounding build in, not sure if you can do it shorter if mixed with @user902383's solution.

Ungolfed

```<code>int[] f(int i) {
    return new int[]{
            i,
            i += i / 3 + 0.5,
            i -= i / 3 - 0.5,
            i += 1.5};
}
</code>```

Output with i=9

```<code>[9, 12, 8, 9]
</code>```

Title: The Nine Pattern

Body:
Java, 64 bytes

int[]f(int i){return new int[]{i,i+=i/3+0.5,i-=i/3-0.5,i+=1.5};}

Notes

This has the required rounding build in, not sure if you can do it shorter if mixed with @user902383's solution.

Ungolfed

int[] f(int i) {
    return new int[]{
            i,
            i += i / 3 + 0.5,
            i -= i / 3 - 0.5,
            i += 1.5};
}

Output with i=9

[9, 12, 8, 9]


答:
Scratch, 16 bytes

(scoring used)

Stopping the project is the closest thing to an error that I can get.

Title: Don't google "google"

Body:
We all know that if you google the word "google" it will break the internet.

Your task is to create a function that accepts one string and returns its length, in the fewest possible Unicode characters.

However, if the given string is google (lowercase), it will cause an error.

For example, g('bing') will return 4 but g('google') will cause an error.

Please provide an example of usage, and the error if possible.


答:
R 109 bytes

```<code>y=sapply(x<-2:scan(),FUN=function(x)x-sum(unique(as.numeric(gmp::factorize(x))^2)));c(x[which.max(y)],max(y))
</code>```

I cheated and used a package, gmp.

Body:
R 109 bytes

y=sapply(x<-2:scan(),FUN=function(x)x-sum(unique(as.numeric(gmp::factorize(x))^2)));c(x[which.max(y)],max(y))

I cheated and used a package, gmp.


问:
Divisor reduction
A divisor of a number n is any number that evenly divides n, including 1 and n itself. The number of divisors d(n) is how many divisors a number has. Here's d(n) for the first couple n:

```<code>n    divisors    d(n)
1    1           1
2    1, 2        2
3    1, 3        2
4    1, 2, 4     3
5    1, 5        2
6    1, 2, 3, 6  4
</code>```

We can repeatedly subtract the number of divisors from a number. For example:

```<code>16                  = 16
16 - d(16) = 16 - 5 = 11
11 - d(11) = 11 - 2 = 9
 9 - d( 9) =  9 - 3 = 6
 6 - d( 6) =  6 - 4 = 2
 2 - d( 2) =  2 - 2 = 0
</code>```

In this case it took 5 steps to get to 0.

Write a program or function that given a nonnegative number n returns the number of steps it takes to reduce it to 0 by repeated subtraction of the number of divisors.

Examples:

```<code>0, 0
1, 1
6, 2
16, 5
100, 19
100000, 7534
</code>```

答:
Racket - 126 bytes Down to 98 bytes  91 bytes

An extremely naive solution - could probably be cut down a lot with a decent algorithm and some lisp tricks that I don't know

```<code>(define(g x[c 0][d 0][i 2])(cond[(= x 0)c][(= i x)(g d(+ 1 c))][(=(modulo x i)0)(g x c d(+ 1 i))][else(g x c(+ 1 d)(+ 1 i))]))
</code>```

Edit: explanation by request. As I said, this is an extremely naive recursive solution and can be much much shorter.

```<code>(define (g x [c 0] [d 0] [i 2]) ;g is the name of the function - arguments are x (input), c (counter for steps), d (non-divisor counter), i (iterator)
  (cond
    [(= x 0) c] ;once x gets to 0 c is outputted
    [(= i x) (g d (+ 1 c))] ;if iterator reaches x then we recurse with d as input and add 1 to c
    [(= (modulo x i) 0) (g x c d (+ 1 i))] ;checks if iterator is non divisor, then adds it to d and increments iterator
    [else(g x c (+ 1 d) (+ 1 i))])) ;otherwise just increments iterator
</code>```

Edit 2: 98 byte version with a less dumb algorithm (still pretty dumb though and can be shorter)

```<code>(define(g x)(if(< x 1)0(+ 1(g(length(filter(λ(y)(>(modulo x y)0))(cdr(build-list x values))))))))
</code>```

Explanation:

```<code>(define (g x) ;function name g, input x
  (if (< x 1)
      0 ;returns 0 if x < 1 (base case)
      (+ 1 ;simple recursion - adds 1 to output for each time we're looping
         (g (length ;the input we're passing is the length of...
              (filter (λ (y) (> (modulo x y) 0)) ;the list where all numbers which are 0 modulo x are 0 are filtered out from...
                             (cdr (build-list x values)))))))) ;the list of all integers up to x, not including 0
</code>```

Edit 3: Saved 7 bytes by replacing (cdr(build-list x values)) with (build-list x add1)

```<code>(define(g x)(if(< x 1)0(+ 1(g(length(filter(λ(y)(>(modulo x y)0))(build-list x add1)))))))
</code>```

Title: Divisor reduction

Body:
Racket - 126 bytes Down to 98 bytes  91 bytes

An extremely naive solution - could probably be cut down a lot with a decent algorithm and some lisp tricks that I don't know

(define(g x[c 0][d 0][i 2])(cond[(= x 0)c][(= i x)(g d(+ 1 c))][(=(modulo x i)0)(g x c d(+ 1 i))][else(g x c(+ 1 d)(+ 1 i))]))

Edit: explanation by request. As I said, this is an extremely naive recursive solution and can be much much shorter.

(define (g x [c 0] [d 0] [i 2]) ;g is the name of the function - arguments are x (input), c (counter for steps), d (non-divisor counter), i (iterator)
  (cond
    [(= x 0) c] ;once x gets to 0 c is outputted
    [(= i x) (g d (+ 1 c))] ;if iterator reaches x then we recurse with d as input and add 1 to c
    [(= (modulo x i) 0) (g x c d (+ 1 i))] ;checks if iterator is non divisor, then adds it to d and increments iterator
    [else(g x c (+ 1 d) (+ 1 i))])) ;otherwise just increments iterator

Edit 2: 98 byte version with a less dumb algorithm (still pretty dumb though and can be shorter)

(define(g x)(if(< x 1)0(+ 1(g(length(filter(λ(y)(>(modulo x y)0))(cdr(build-list x values))))))))

Explanation:

(define (g x) ;function name g, input x
  (if (< x 1)
      0 ;returns 0 if x < 1 (base case)
      (+ 1 ;simple recursion - adds 1 to output for each time we're looping
         (g (length ;the input we're passing is the length of...
              (filter (λ (y) (> (modulo x y) 0)) ;the list where all numbers which are 0 modulo x are 0 are filtered out from...
                             (cdr (build-list x values)))))))) ;the list of all integers up to x, not including 0

Edit 3: Saved 7 bytes by replacing (cdr(build-list x values)) with (build-list x add1)

(define(g x)(if(< x 1)0(+ 1(g(length(filter(λ(y)(>(modulo x y)0))(build-list x add1)))))))