答:
5 years, Go 1.0, 1.1, 1.4, 1.5, 1.6: 285 257 bytes

(1.2 was released in 2013 like 1.1, 1.3 in 2014 like 1.4, and 1.7 in 2016 like 1.6.)

Have not tested this out on every version because I can access only 1.6, but it should work in theory! Language changes would likely have caused the program not to compile, so I relied on standard library changes.

```<code>package main
import(."fmt"
."reflect"
."time")
func main(){s:="6"
if _,e:=Parse("2016-Sep-30","2016-Sep-31");e==nil{s="5"}
if Sprint(ValueOf(0))!="0"{s="4"}
if Sprint(&map[int]int{1:1})[0]!='&'{s="3"}
if string(0xd800)==string(0xfffd){s="2"}
Print("201"+s)}
</code>```

Ungolfed and commented:

```<code>package main

import (
    "fmt"
    "reflect"
    "time"
)   package main

import (
    . "fmt"
    . "reflect"
    . "time"
)

func main() {
    s := "6"
    // 1.6: time.Parse rejects invalid days
    if _, e := Parse("2016-Sep-30", "2016-Sep-31"); e == nil {
        s = "5"
    }
    // 1.5: A reflect.Value now prints what it holds, rather than use
    // its String() method
    if Sprint(ValueOf(0)) != "0" {
        s = "4"
    }
    // 1.4: Printing pointers to maps gives the map instead of the address
    if Sprint(&map[int]int{1: 1})[0] != '&' {
        s = "3"
    }
    // 1.1: Unicode surrogate halves are no longer allowed
    if string(0xd800) == string(0xfffd) {
        s = "2"
    }
    Print("201" + s)
}
</code>```

Title: When was this language released?

Body:
5 years, Go 1.0, 1.1, 1.4, 1.5, 1.6: 285 257 bytes

(1.2 was released in 2013 like 1.1, 1.3 in 2014 like 1.4, and 1.7 in 2016 like 1.6.)

Have not tested this out on every version because I can access only 1.6, but it should work in theory! Language changes would likely have caused the program not to compile, so I relied on standard library changes.

package main
import(."fmt"
."reflect"
."time")
func main(){s:="6"
if _,e:=Parse("2016-Sep-30","2016-Sep-31");e==nil{s="5"}
if Sprint(ValueOf(0))!="0"{s="4"}
if Sprint(&map[int]int{1:1})[0]!='&'{s="3"}
if string(0xd800)==string(0xfffd){s="2"}
Print("201"+s)}

Ungolfed and commented:

package main

import (
    "fmt"
    "reflect"
    "time"
)   package main

import (
    . "fmt"
    . "reflect"
    . "time"
)

func main() {
    s := "6"
    // 1.6: time.Parse rejects invalid days
    if _, e := Parse("2016-Sep-30", "2016-Sep-31"); e == nil {
        s = "5"
    }
    // 1.5: A reflect.Value now prints what it holds, rather than use
    // its String() method
    if Sprint(ValueOf(0)) != "0" {
        s = "4"
    }
    // 1.4: Printing pointers to maps gives the map instead of the address
    if Sprint(&map[int]int{1: 1})[0] != '&' {
        s = "3"
    }
    // 1.1: Unicode surrogate halves are no longer allowed
    if string(0xd800) == string(0xfffd) {
        s = "2"
    }
    Print("201" + s)
}


问:
When was this language released?
Your challenge is simple. You need to write a program that prints to either STDOUT or a file the year the language it is written in was released. Because this is such a simple task, the twist is that it must be written in as many different languages as possible.

Your score is the total number of different years that are correctly printed.

For each language you use, you must

Specify which version of the language you are using. (If there are multiple versions)

Specify what year that version was first released, and

Provide a link to a page proving the date of your version/language.

Any one of these counts as release date proof, as long as it specifies the version number (if applicable) and a release date.

A wikipedia page.

An esolangs page.

The language's official website. A github page or similar counts, as long as it has a release date. (Latest commit does not count, unless there is a version number somewhere in the code)

If there are not multiple versions or releases of a language, just use the initial release date of the language.

Minor versions of the same language do count as different languages, as long as they come from different years and still produce the correct output. You may not use any builtins that give you information (including release date) about the current version of the language you are using. For example, this is an invalid python submission:

```<code>import platform
i = platform.python_version()
if i == '3.5':
    print(2015)
if i == '3.4':
    print(2014)
if i == '3.3':
    print(2012)
...
</code>```

Whichever submission correctly prints the most distinct years wins!

Rules

Each program must print out the language year and nothing more. A trailing newline (windows style or *nix style) is allowed.

No programs may take any input.

In case of a tie, the shortest code scored in bytes wins. You may use whatever encoding you like for this, but all programs must use the same encoding.

Any of the programs may print to STDERR, or throw runtime/compile time errors and warnings as long as the correct output is still printed to STDOUT or a file.

Different languages may use different IO methods, but they most all be full programs, (functions not allowed for this challenge) and follow one of our default IO methods allowed.

Happy <s>golfing</s> polyglotting!

ContentLicense: CC BY-SA 3.0

Title: When was this language released?

Body:
A Brief History of 2D Programming Languages: 16 (+2) years

v19977/2{@{{4{\_______>/02&&&#????        *    P+++++1P1P-1P+1E     *                         *
\'\02'oo100@n590@n;                       *                         *                         *
>"8991",,,;5-;,@                          *                         *                         *
   *                                      *                         *                         *
  \ *              ++++++++++++++++++++++++  ++++++++++++++++++++++++  ++O--OO++++++++OX*******      *
     *   #2018O@       *                  *      *                  *      *                  *      *
      *                *                  *      *                  *      *                  *      *
       *               *                  *      *                  *      *                  *      *
        *           ****    ****          *   ****    ****          *   ****    ****          *   ****    *****
         *         *   *   *    *         *  *   *   *    *         *  *   *   *    *         *  *   *   *
          *        *   *  *      *        *  *   *  *      *        *  *   *  *      *        *  *   *  *
           *      *    * ****     *       * *    * ****     *       * *    * ****     *       * *    * ****
            *     *    *     *            * *    *     *            * *    *     *            * *    *     *
R"2014";     *****      *******       ******      *******       ******      *******       ******      *******

 x
x%"2010"x
 x

$'main'        \/\/\/\
 \-[2005]o-#   \++++++\
               /++++++/
               \++++++\
               /++++++/
               \/\/\/\++.--..+++.#

S1^2^2^6^8MAOUOAOOF

      /K:0:1:@

  >      "7102"4&o@

|        }+++++[>++++++++++<-]>.--..++++++.@

Did I mention that I like 2D programming languages?

1993: Befunge

The language that (allegedly, see the last section) started it all. In Befunge, you can redirect the control flow with <v>^, but the now ubiquitous mirrors \ and / weren't a thing yet. The Befunge interpreter used on Anarchy Golf ignores unknown commands. We can use this to distinguish the Befunge family from the ><> family. Hence, the code executed by Befunge is this:

v
\
>"8991",,,;5-;,@

The "8991" pushes the individual characters onto the stack. ,,, prints the first three of them. Then ; is unknown (which we'll use to distinguish it from Befunge 98), 5- turns the 8 into a 3 and , prints that as well before @ terminates the program.

1997: Wierd

Writing this part of the solution took me probably as long as writing all the others and fitting them together...

Wierd only knows two symbols: space, and everything else. The instruction pointer tries to follow the path formed by the non-space characters, starting diagonally from the top left corner and always trying to go as straight as possible. The bends in the path form the actual instructions (with the degrees of the turn determining which instruction to execute). So the code seen by Wierd is this:

v1997                                     *                         *                         *
 '                                        *                         *                         *
  8                                       *                         *                         *
   *                                      *                         *                         *
    *              ++++++++++++++++++++++++  ++++++++++++++++++++++++  ++O--OO++++++++OX*******      *
     *                 *                  *      *                  *      *                  *      *
      *                *                  *      *                  *      *                  *      *
       *               *                  *      *                  *      *                  *      *
        *           ****    ****          *   ****    ****          *   ****    ****          *   ****    *****
         *         *   *   *    *         *  *   *   *    *         *  *   *   *    *         *  *   *   *
          *        *   *  *      *        *  *   *  *      *        *  *   *  *      *        *  *   *  *
           *      *    * ****     *       * *    * ****     *       * *    * ****     *       * *    * ****
            *     *    *     *            * *    *     *            * *    *     *            * *    *     *
             *****      *******       ******      *******       ******      *******       ******      *******

The 1997 at the top isn't actually executed, but Wierd lets us read it from the source code, which is a lot shorter than trying to construct the character codes for the four digits itself (even if it doesn't look like it...). I don't feel like breaking this entire thing down, but you can clearly see the four repeated sections. What this does is that we first store 1 on the stack and then each of those four sections increments this 1, and then branches. The bottom branch pushes another 1, retrieves the source character at these coordinates and prints it, whereas the top branch is redirected to the next section. You might wonder why the ends of the paths are so unnecessarily long, but that's because when Wierd hits the end of a path it tries to jump to a nearby path before deciding that it should terminate the current branch. To avoid this, we need to move these ends sufficiently far away from any other code.

1998: Befunge 98

Befunge got a fairly well-known update in 1998 with a very rigorous spec that can be generalised to arbitrary dimensions (and I think also arbitrary topologies). It's largely backwards-compatible with Befunge though, which makes it fairly easy to polyglot the two. This Befunge still didn't have any mirrors, so the executed path is the same as for Befunge 93:

v
\
>"8991",,,;5-;,@

The difference is that Befunge 98 doesn't ignore the ;. Instead it acts a bit like a comment in that all commands until the next ; are ignored. This way, we don't decrement that 8 to 3 and print the 1998 as is.

2001: <s>A Space Od...</s> PingPong

2001 is the year of Piet, but I really didn't feel like polyglotting an image file with all the other programs, so here is a lesser known 2D language. It seems to have quite a lot of features (which we're not going to use). Thanks to Sp3000 for finding the original interpreter (which is the only dead link on the archived version of the official website).

PingPong is somewhat unusual in that it has only mirrors and no <v>^ redirectors. So this moves through the v19977 at the start and then hits the mirror which wraps it to the bottom. The relevant code is then:

v19977/

...

      /K:0:1:@

...

The actual code is quite simple: K pushes 20, the digits push themselves, : prints an integer and @ terminates the program.

2003: SNUSP

This is first language where things get a bit easier, because SNUSP supports an explicit entry point. That entry point is marked by $. Judging from some articles on esolangs, this language has inspired several others, but unfortunately, at the end of the day it's just a Brainfuck derivative. That said, I think the way this sets the current cell to 48 is quite neat (and was stolen from the esolangs article). Here is the relevant part of the code:

$'main'        \/\/\/\
               \++++++\
               /++++++/
               \++++++\
               /++++++/
               \/\/\/\++.--..+++.#

Those are 24 +s and the mirrors send the IP through each one exactly twice.

2004: Axo

For whatever reason, this language does have the <^> redirectors but instead of the usual v it uses %. Hence this just moves across the first line. The relevant code is:

v19977/2{@{{4{\

We push a few digits to begin with, perform a division. Then 2{ prints the 2, @ clears the stack. {{ prints two (implicit) 0s. 4{ prints the 4 and \ terminates the program.

2005: Rail

2005 was a difficult choice. For no other year did I find as many 2D languages, and there is ADJUST and Archway, both of which start in the lower left corner (which would have made them easy additions). I like Rail though and since it has an explicit entry point is wasn't hard to add either. Rail looks for a line start with $'main' and starts moving south-east from the $. That means the relevant code is:

$'main'
 \-[2005]o-#

The \ and - are just tracks (no-ops). The [2005] is a string literal which o prints before # terminates the program.

2006: BestFriends.js

A two-dimensional Brainfuck. There is another interesting language for this year called Black, which starts at coordinate (3,3) (1-based) which would have made using this in a polyglot interesting, too. I couldn't find an interpreter though. So we'll have to work with another BF-derivative instead...

The interesting thing about this one is that it doesn't format the grid into lines with linefeeds like most other 2D languages. Instead | is used as the line separator. Since I didn't use | for any other languages, I could simply put a | on the last line which makes the entire rest of the program a single line as far as BF.js is concerned. The relevant code is then this (turning the | into an actual linefeed):

v19977/2{...
        }+++++[>++++++++++<-]>.--..++++++.@

BF.js uses neither <v>^ nor mirrors. The only ways to redirect control flow is with {} which turn the IP direction by 90°. So those braces move the IP to the second line. The remainder is a plain Brainfuck solution (not particularly well golfed) that sets a cell to 50 (code point of 2) and then prints 2006 by shifting the value around a bit. @ terminates the program.

2008: BrainSpace 1.0

For this year I really wanted to use DOBELA which uses multiple entry points and looks like the lovechild of Fission and Ziim. Unfortunately, I haven't been able to get the interpreter to work. So here is another BF derivative (the last one, I promise).

As opposed to the last one, this one knows both <v>^ and mirrors, so the relevant code is:

v
\'\
  8

  \ *              ++++++++++++++++++++++++  ++++++++++++++++++++++++  ++O--OO++++++++OX

This one doesn't have the usual BF-style [] loop (instead you'd need to form an actual 2D loop), so I just decided to hardcode the 50 since I had a ton of characters in a row from Wierd anyway. Note that the ' and 8 are ignored, the * is a conditional trampoline which we can ignore and the O is Brainfuck's .. The X terminates the program.

2009: ><>

Probably the most popular Fungeoid (other than Befunge itself) at least around these parts. ><> has both <v>^ and mirrors but also string literals, so the executed code is this:

v
\'\02'oo100@n590@n;

The string literal mostly serves to skip the \ we used for BrainSpace 1.0 but while we're at it we might as well push the first two characters. oo prints them. Then 100 pushes three digits, @ shoves the top one to the bottom and n prints the 0 underneath. We do the same thing again with 590 which prints the 9. If you're wondering why I'm not just printing 2009 as is, wait for 2015. ; terminates the program.

2010: Cardinal

This one was simple, because it has an explicit entry point at %. However, this one creates 4 IPs in all directions (hence the language name, I suppose), and we need to get rid of 3 of them. Here is the relevant code:

 x
x%"2010"x
 x

Well, yeah. (In Cardinal, string mode prints directly instead of pushing the characters onto a stack.)

2011: RunR

Another language with an explicit entry point (by David Catt who has created a few other very nice esolangs), this time at S. This makes the relevant code this part:

S1^2^2^6^8MAOUOAOOF

RunR is a bit interesting because most operations work with a sort of register and values need to be moved to the stack explicitly for binary operations. The digits set the register values to themselves and ^ pushes the current register to the stack. Then M is multiplication (register times value popped from stack), U is subtraction, A is addition, O is output. F terminates the program.

2012: Ropy

Like Wierd, Ropy tries to follow sections of non-space characters, but here the bends don't determine the commands. In fact, it turns out that Ropy is more similar to my own Labyrinth in that the chosen direction depends on the top of the stack. However, we don't really need to worry about that here, because Ropy just moves along the first line:

v19977/2{@{{4{\_______>/02&&&#????

There's a lot of stuff we can ignore up to the >. All we need to know is that the top of the stack will at that point be a 4 and there'll be 2 below.

> duplicates the 4, / is division turning it into a 1. Then we push 02. &&& joins the top four numbers of the stack in reverse order, giving 2012. # outputs it. ???? just clears the stack because otherwise the top of the stack is output as well.

One point of interest is that the second 7 in 19977 was added because of Ropy. The / division in Ropy does top / second (opposite of the usual order in many stack-based languages), where 7 / 9 would give 0. If we had a zero on top of the stack, Ropy would do some wild stuff with its direction of movement, so we need to push the other 7 to ensure that the top of the stack remains positive and Ropy keeps moving east.

2014: Fission

With its explicit entry points, this one is easy. RDLU create atoms (instruction pointers) in the corresponding direction, so the relevant bit is just this:

R"2014";

Note that there's a U in the source code as well, but that atom eventually hits one of the * from Wierd, which terminates the program (and this atom takes a lot longer than the R needs to print 2014).

2015: Gol><>

Sp3000's more powerful ><> derivative. It's largely backwards compatible with ><> so the executed code is still:

v
\'\02'oo100@n590@n;

However, the rotation direction of @ was changed, which is the standard trick to distinguish ><> and Gol><> in polyglots, so this one prints 15 instead of 09. Hence the weirdness in the second half of the program.

2016: CSL

CSL is quite interesting in that commands aren't executed immediately. Instead, each command is pushed onto a command-stack and e and E can be used to execute commands from it. The relevant code becomes:

v19977/2{@{{4{\_______>/02&&&#????        *    P+++++1P1P-1P+1E

So the E executes the entire command stack, which means that the stuff in front of it is executed in reverse. We only need to look up to the *:

1+P1-P1P1+++++P*

The 1s push themselves onto the data stack. + and - are decrement/increment. P prints the top of the stack. Then * tries to multiply the top two values of the stack. However, the stack is empty, so this terminates the program.

At this point we get to languages which were released after this challenge was posted, so I'm not really counting them for the score, especially since I created these myself (not with this challenge in mind though). However, they do have some novel IP movement semantics, which made it easy to fit them into the polyglot while also adding something interesting to this showcase of 2D languages.

2017: Alice

Alice was designed to be a feature-rich Fungeoid. One interesting difference to the majority of (but not all) other 2D languages is that the IP can move either orthogonally, or diagonally. Switching between these also changes the semantics of almost all commands in the language. Furthermore, Alice supports both the traditional <^>v direction setters and \/ mirrors, but mirrors have very unique behaviour in Alice (which makes it easy to lead the Alice IP to a so far unused portion of the code).

While most languages treat \ and / as if they were mirrors at a 45° angle, and the IP as a light ray bouncing off of it, Alice treats them as having a 67.5° angle (which is closer to the angle of the actual slash glyphs), and the IP also moves through the mirror (hence the language's name). Due to this angle, mirrors switch between movement along orthogonal or diagonal directions. Furthermore, while in Ordinal mode (i.e. while the IP moves along diagonals), the grid doesn't wrap around and instead the IP bounces off the edges (whereas in Cardinal mode it does wrap around).

All in all, the code executed by Alice is the following:

v19
\ \

...

  >      "7102"4&o@

...

The IP starts in the top left corner as usual, v sends it south. Now the \ reflects the IP to move northwest, where it immediately bounces off the left edge of the grid (and moves northeast instead). 1 can be ignored, the IP bounces off the top edge to move southeast next. We hit another \ which reflects the IP north. 9 can also be ignored and then the IP wraps to the bottom of the grid. After a couple of lines we redirect it east with > for convenience. Then "7102" pushes the code points of the 2017, 4&o prints those four characters and @ terminates the program.

2018: Wumpus

Wumpus is the first 2D language on a triangular grid, which makes movement through the code quite different (and again lets us reach an unused part of the code easily). So instead of thinking of each character in the grid as a little square, you should think of them as alternating upward and downward triangles. The top left corner is always an upward triangle.

Wumpus doesn't have direction setters like <^>v, but it does have mirrors \/. However, due to the triangular grid, these work differently from most other languages. The IP bounces off them like a light ray (as usual) but you should think of them as having an angle of 60° degrees. So an IP moving east will end up moving along the northwest axis of the grid.

As another difference to most other languages, the edges of the grid don't wrap, but the IP bounces off the edges instead (as if those edge cells contained the appropriate mirrors). Another fun little detail is that diagonals through the triangular grid actually look like staircases in the source code.

With that in mind, the code executed by Wumpus is the following (where I've replaced spaces with . for clarity:

v19977/
   02
  89
 ..
..
.....*...#2018O@

The v19977 are just junk that we can ignore. / sends the IP northwest, where it moves through the 977 (from the right) again while bouncing off the top edge. Then the IP moves southwest through the 2089 and a bunch of spaces, before it hits the left edge to be reflected east again. * is also junk. Then finally #2018 pushes 2018, O prints it and @ terminates the program.

Missing years

Finally, some notes about years I haven't covered.

While researching 2D languages to find suitable ones across the years which could be used in a polyglot, I found out that contrary to popular belief, Befunge was not the first 2D language. That title seems to be held by Biota which was already created in 1991. Unfortunately, the language doesn't have any output, so I wasn't able to use it for this challenge.

As far as I can tell no 2D languages were created in 1992 and 1995. That leaves a few years I haven't covered:

1994: Orthagonal was created, independently of Befunge. The languages are semantically quite similar actually, but Orthagonal doesn't actually lay out the source code in 2D. Instead each line is an (x, y, instruction) tuple. I even obtained the language spec and original interpreter from the creator Jeff Epler, but in the end, the fact that the syntax isn't 2D made the language unsuitable for this polyglot.

1996: Orthogonal, a successor to Orthagonal (created by someone else) was created, but for the purposes of this polyglot suffers the same problems as Orthagonal.

1999: The only language I could find was Chris Pressey's cellular automaton REDGREEN. Unfortunately, as opposed to its predecessor RUBE, it doesn't seem to have any I/O semantics.

2000: There's another cellular automaton of Chris Pressey's called noit o' mnain worb but it also doesn't have any I/O. There's also Numberix which I haven't tried to get running and I'm not sure whether it would ignore non-hex characters in the source code.

2002: There's Clunk with no I/O and ZT whose language specification terrifies me.

2007: I found three languages here. Zetaplex is image based (so nope) and RubE On Conveyor Belts seems to require a header with a rather strict format which would have messed with the first line of the program. There's also Cellbrain by Quintopia, but it also seems to require a specific header.

2013: Again, I found three languages. Fishing might be possible with a good amount of restructuring but it would require the program to begin with a valid dock. Quipu, from memory, is way too strict about its syntax to allow much polyglotting. And Swordfish is another member of the ><> family, but unfortunately I haven't been able to find an interpreter. Otherwise, this one would probably be fairly easy to add.

If anyone is interested, here is the complete list of implemented 2D languages sorted by years as far as I could find them (at the time this answer was posted). If any are missing from this list, please let me know in chat as I'd be really interested in a complete list.


问:
Compute the Mertens function
Given a positive integer n, compute the value of the Mertens function \$M(n)\$ where:

$$M(n) = \Sigma_{k=1}^{n}\mu(k)$$

and \$\mu(k)\$ is the Möbius function where \$μ(k) = 1\$ if \$k\$ has an even number of distinct prime factors, \$-1\$ if \$k\$ has an odd number of distinct prime factors, and \$0\$ if the prime factors are not distinct.

This is code-golf so create the shortest code for a function or program that computes the Mertens function for an input integer n > 0.

This is the OEIS sequence A002321.

Test Cases

```<code>n M(n)
1 1
2 0
3 -1
4 -1
5 -2
6 -1
7 -2
8 -2
9 -2
10 -1
117 -5
5525 5
7044 -25
8888 4
10000 -23
</code>```

答:
CJam (20 bytes)

```<code>qiM{_,:)(@@f/{j-}/}j
</code>```

Online demo

Uses the formula from OEIS

sum(k = 1..n, a([n/k])) = 1. - David W. Wilson, Feb 27 2012

and CJam's memoising operator j.

Dissection

```<code>qi       e# Read stdin as an integer
M{       e# Memoise with no base cases
         e#   Memoised function: stack contains n
  _,:)(  e#   Basic manipulations to give n [2 .. n] 1
  @@f/   e#   More basic manipulations to give 1 [n/2 ... n/n]
  {j-}/  e#   For each element of the array, make a memoised recursive call and subtract
}j
</code>```

ContentLicense: CC BY-SA 4.0

Title: Compute the Mertens function

Body:
CJam (20 bytes)

qiM{_,:)(@@f/{j-}/}j

Online demo

Uses the formula from OEIS

sum(k = 1..n, a([n/k])) = 1. - David W. Wilson, Feb 27 2012

and CJam's memoising operator j.

Dissection

qi       e# Read stdin as an integer
M{       e# Memoise with no base cases
         e#   Memoised function: stack contains n
  _,:)(  e#   Basic manipulations to give n [2 .. n] 1
  @@f/   e#   More basic manipulations to give 1 [n/2 ... n/n]
  {j-}/  e#   For each element of the array, make a memoised recursive call and subtract
}j


问:
Yes, of course I'm an adult!
I think we've all done this as a kid: some websites require a minimum age of 18, so we just subtract a few years from the year of birth and voilà, we 'are' 18+.

In addition, for most rides at amusement parks the minimum height to enter is 1.40 meters (here in The Netherlands it as at least). Of course this can be cheated less easily than age, but you could wear shoes with thick heels, put your hair up, wear a hat, stand on your toes, etc.

Input:

Your program/function accepts a positive integer or decimal.

Output:

Is the input an integer >= 18? Simply print the input.

Is the input an integer 0-17? Print 18.

Is the input a decimal >= 1.4? Simply print the input.

Is the input a decimal 0.0-1.4? Print 1.4.

Challenge rules:

Assume the input will always be in the range of 0-122 (oldest woman ever was 122) or 0.0-2.72 (tallest man ever was 2.72).

You are allowed to take the input as a String, object, or anything else you prefer.

The decimal inputs will never have more than three decimal places after the decimal point.

2 or 2. both aren't valid outputs for 2.0. You are free to output 2.00 or 2.000 instead of 2.0 however.

Just like the input the output will never have more than three decimal places after the point.

General rules:

This is code-golf, so shortest answer in bytes wins.

Don't let code-golf languages discourage you from posting answers with non-codegolfing languages. Try to come up with an as short as possible answer for 'any' programming language.

Standard rules apply for your answer, so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters, full programs. Your call.

Default Loopholes are forbidden.

If possible, please add a link with a test for your code.

Also, please add an explanation if necessary.

Test cases:

```<code>0      ->  18
1      ->  18
2      ->  18
12     ->  18
18     ->  18
43     ->  43
115    ->  115
122    ->  122

0.0    ->  1.4
1.04   ->  1.4
1.225  ->  1.4
1.399  ->  1.4
1.4    ->  1.4
1.74   ->  1.74
2.0    ->  2.0
2.72   ->  2.72
</code>```

答:
Java 8, <s>90</s> <s>61</s> 57 bytes

i->(i+"").contains(".")?(float)i<1.4?1.4:i:(int)i<18?18:i
```
<p>-4 bytes returning <code>Object</code> instead of <code>String</code>; and some additional bytes converting Java 7 to 8.<br />
-4 byte taking the input as <code>Object</code> instead of <code>String</code> as well.</p>
<p><strong>Explanation:</strong></p>
<p>Try it here.</p>
<pre class="lang-java prettyprint-override"><code>i->                      // Method with Object as both parameter and return-type
  (i+"").contains(".")?  //  If the input as String contains a dot:
   (float)i<1.4?         //   If the input is a float below 1.4:
    1.4                  //    Return double 1.4
   :                     //   Else:
    i                    //    Return the input-float as is
  :(int)i<18?            //  Else if the input is an integer below 18:
   18                    //   Return integer 18
  :                      //  Else:
   i                     //   Return the input-integer as is
</code>```

Title: Yes, of course I'm an adult!

Body:
Java 8, <s>90</s> <s>61</s> 57 bytes

i->(i+"").contains(".")?(float)i<1.4?1.4:i:(int)i<18?18:i

-4 bytes returning Object instead of String; and some additional bytes converting Java 7 to 8.

-4 byte taking the input as Object instead of String as well.

Explanation:

Try it here.

i->                      // Method with Object as both parameter and return-type
  (i+"").contains(".")?  //  If the input as String contains a dot:
   (float)i<1.4?         //   If the input is a float below 1.4:
    1.4                  //    Return double 1.4
   :                     //   Else:
    i                    //    Return the input-float as is
  :(int)i<18?            //  Else if the input is an integer below 18:
   18                    //   Return integer 18
  :                      //  Else:
   i                     //   Return the input-integer as is


答:
15 years, Python

Versions: 0.9.1, 2.0.0, 2.2.0, 2.2.2, 2.5.0, 2.5.1, 3.0.0, 3.1.0, 3.1.3, 3.2.1, 3.3.0, 3.3.3, 3.4.0, 3.5.0 and 3.6.0a4. Versions not linked can be found on the downloads page.

The release date of 0.9.1 can be found here. Unfortunately I had to skip a large bunch of years due to missing old versions and compilation problems on my computer. The represented years are 1991, 2000-2002 and 2006-2016.

Tested on Arch Linux, using the gzipped versions.

# Note: This file needs a trailing newline due to 0.9.1

# 0.9.1: No bitwise operators
# This one errors out by division by zero.
try:
    eval('1&2')
except:
    print(1991)
    1/0

import sys

# 2.0.0: repr('\n') gives "'\012'" instead of "'\n'"
# == doesn't exist until Python 0.9.3 and <> doesn't exist in Python 3, hence we
# use <. Also, 0.9.1 doesn't have double quoted strings.
if repr('\n') < '\'\\n\'':
    print(2000)
    sys.exit()

# 2.2.0: email module still has a _Parser class - module revamped in 2.2.2
# I would use whether or not True exists as a name here, but weirdly "True"
# worked in 2.2.2 even though the docs say it was introduced in 2.3...
try:
    import email
    email._Parser
    print(2001)
    sys.exit()
except AttributeError:
    pass

# 2.2.2: a in b only works for strings a of length 1.
try:
    eval('"art" in "Martin"')
except TypeError:
    print(2002)
    sys.exit()

# 2.5.0: int() allows null bytes in integer to convert when given an explicit
# base.
try:
    print(int('2006\x00Hello, World!', 10))
    exit()
except ValueError:
    pass

# 2.5.1: pow overflows
# Note that we can't use ** here since that doesn't exist in 0.9.1.
if pow(2, 100) < 1:
    print(2007)
    exit()

# 3.0.0: round returns a float rather than an int.
if str(round(1, 0)) > '1':
    print(2008)
    exit()

# 3.1.0: bug caused complex formatting to sometimes drop the real part.
if format(complex(-0.0, 2.0), '-') < '(-':
    print(2009)
    exit()

# 3.1.3: str of a float is shorter than the repr of the same float.
if str(1.0/7) < repr(1.0/7):
    print(2010)
    exit()

# 3.2.1: For some weird reason, u'...' Unicode strings were disabled then
# re-enabled later.
try:
    eval('u"abc"')
except:
    print(2011)
    exit()

# 3.3.0: int still works without a first argument.
try:
    int(base=10)
    print(2012)
    exit()
except TypeError:
    pass

# 3.3.3: no enum module :(
try:
    import enum
except ImportError:
    print(2013)
    exit()

# 3.4.0: PEP 448 (additional unpacking generalisations) not implemented yet
try:
    eval('[*[1], *[2], *[3]]')
except SyntaxError:
    print(2014)
    exit()

# 3.5.0: No f-strings
try:
    eval('f"abc"')
except SyntaxError:
    print(2015)
    exit()

print(2016)
```

Title: When was this language released?

Body:
Your challenge is simple. You need to write a program that prints to either STDOUT or a file the year the language it is written in was released. Because this is such a simple task, the twist is that it must be written in as many different languages as possible.

Your score is the total number of different years that are correctly printed.

For each language you use, you must

Specify which version of the language you are using. (If there are multiple versions)

Specify what year that version was first released, and

Provide a link to a page proving the date of your version/language.

Any one of these counts as release date proof, as long as it specifies the version number (if applicable) and a release date.

A wikipedia page.

An esolangs page.

The language's official website. A github page or similar counts, as long as it has a release date. (Latest commit does not count, unless there is a version number somewhere in the code)

If there are not multiple versions or releases of a language, just use the initial release date of the language.

Minor versions of the same language do count as different languages, as long as they come from different years and still produce the correct output. You may not use any builtins that give you information (including release date) about the current version of the language you are using. For example, this is an invalid python submission:

```<code>import platform
i = platform.python_version()
if i == '3.5':
    print(2015)
if i == '3.4':
    print(2014)
if i == '3.3':
    print(2012)
...
</code>```

Whichever submission correctly prints the most distinct years wins!

Rules

Each program must print out the language year and nothing more. A trailing newline (windows style or *nix style) is allowed.

No programs may take any input.

In case of a tie, the shortest code scored in bytes wins. You may use whatever encoding you like for this, but all programs must use the same encoding.

Any of the programs may print to STDERR, or throw runtime/compile time errors and warnings as long as the correct output is still printed to STDOUT or a file.

Different languages may use different IO methods, but they most all be full programs, (functions not allowed for this challenge) and follow one of our default IO methods allowed.

Happy <s>golfing</s> polyglotting!


答:
05AB1E, <s>13</s> 11 bytes

Uses CP-1252 encoding.

```<code>ÐîQ18*14T/M
</code>```

Explanation

```<code>Ð             # triplicate input
 î            # round up
  Q           # check for equality
   18*        # multiply 18 by this (18 if input is int, else 0)
      14T/    # push 14 / 10
          M   # take max of stack (input and 1.4 or 18)
</code>```

Try it online

Title: Yes, of course I'm an adult!

Body:
I think we've all done this as a kid: some websites require a minimum age of 18, so we just subtract a few years from the year of birth and voilà, we 'are' 18+.

In addition, for most rides at amusement parks the minimum height to enter is 1.40 meters (here in The Netherlands it as at least). Of course this can be cheated less easily than age, but you could wear shoes with thick heels, put your hair up, wear a hat, stand on your toes, etc.

Input:

Your program/function accepts a positive integer or decimal.

Output:

Is the input an integer >= 18? Simply print the input.

Is the input an integer 0-17? Print 18.

Is the input a decimal >= 1.4? Simply print the input.

Is the input a decimal 0.0-1.4? Print 1.4.

Challenge rules:

Assume the input will always be in the range of 0-122 (oldest woman ever was 122) or 0.0-2.72 (tallest man ever was 2.72).

You are allowed to take the input as a String, object, or anything else you prefer.

The decimal inputs will never have more than three decimal places after the decimal point.

2 or 2. both aren't valid outputs for 2.0. You are free to output 2.00 or 2.000 instead of 2.0 however.

Just like the input the output will never have more than three decimal places after the point.

General rules:

This is code-golf, so shortest answer in bytes wins.

Don't let code-golf languages discourage you from posting answers with non-codegolfing languages. Try to come up with an as short as possible answer for 'any' programming language.

Standard rules apply for your answer, so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters, full programs. Your call.

Default Loopholes are forbidden.

If possible, please add a link with a test for your code.

Also, please add an explanation if necessary.

Test cases:

```<code>0      ->  18
1      ->  18
2      ->  18
12     ->  18
18     ->  18
43     ->  43
115    ->  115
122    ->  122

0.0    ->  1.4
1.04   ->  1.4
1.225  ->  1.4
1.399  ->  1.4
1.4    ->  1.4
1.74   ->  1.74
2.0    ->  2.0
2.72   ->  2.72
</code>```

Body:
05AB1E, <s>13</s> 11 bytes

Uses CP-1252 encoding.

ÐîQ18*14T/M

Explanation

Ð             # triplicate input
 î            # round up
  Q           # check for equality
   18*        # multiply 18 by this (18 if input is int, else 0)
      14T/    # push 14 / 10
          M   # take max of stack (input and 1.4 or 18)

Try it online


Title: Yes, of course I'm an adult!

Body:
Python 2.7, 34 bytes

lambda x:max(x,[18,1.4]['.'in`x`])


答:
PHP, 113 bytes

```<code>for(;$i=$argv[1]--;){for($n=$j=1;$j++<$i;)if(!($i%$j)){$i/=$j;$n++;if(!($i%$j))continue 2;}$a+=$n%2?1:-1;}echo$a;
</code>```

As far as I know php lacks anything like prime number functionality so this is kind of a pain. It's probably possible to do better.

use like:

```<code> php -r "for(;$i=$argv[1]--;){for($n=$j=1;$j++<$i;)if(!($i%$j)){$i/=$j;$n++;if(!($i%$j))continue 2;}$a+=$n%2?1:-1;}echo$a;" 10000
</code>```

Title: Compute the Mertens function

Body:
Given a positive integer n, compute the value of the Mertens function \$M(n)\$ where:

$$M(n) = \Sigma_{k=1}^{n}\mu(k)$$

and \$\mu(k)\$ is the Möbius function where \$μ(k) = 1\$ if \$k\$ has an even number of distinct prime factors, \$-1\$ if \$k\$ has an odd number of distinct prime factors, and \$0\$ if the prime factors are not distinct.

This is code-golf so create the shortest code for a function or program that computes the Mertens function for an input integer n > 0.

This is the OEIS sequence A002321.

Test Cases

```<code>n M(n)
1 1
2 0
3 -1
4 -1
5 -2
6 -1
7 -2
8 -2
9 -2
10 -1
117 -5
5525 5
7044 -25
8888 4
10000 -23
</code>```

Body:
PHP, 113 bytes

for(;$i=$argv[1]--;){for($n=$j=1;$j++<$i;)if(!($i%$j)){$i/=$j;$n++;if(!($i%$j))continue 2;}$a+=$n%2?1:-1;}echo$a;

As far as I know php lacks anything like prime number functionality so this is kind of a pain. It's probably possible to do better.

use like:

 php -r "for(;$i=$argv[1]--;){for($n=$j=1;$j++<$i;)if(!($i%$j)){$i/=$j;$n++;if(!($i%$j))continue 2;}$a+=$n%2?1:-1;}echo$a;" 10000


问:
List all ordered partitions of n
The challenge is to list all ordered partitions (composition (combinatorics)) of a given positive integer n. These are the lists of numbers from 1 to n whose sum is n. For example, given input n = 4, the result should be:

4

  1, 3

  3, 1

  2, 2

  2, 1, 1

  1, 2, 1

  1, 1, 2

  1, 1, 1, 1

The result can be in any order, but must contain each ordered partition once. This means that for n = 4, [1, 1, 2], [1, 2, 1] and [2, 1, 1] must all be part of the result.

Here's my own JavaScript code which achieves this:

```<code>function range(n) {
    for (var range = [], i = 0; i < n; range.push(++i));
    return range;
}

function composition(n) {
    return n < 1 ? [[]] : range(n).map(function(i) {
        return composition(n - i).map(function(j) {
            return [i].concat(j);
        });
    }).reduce(function(a, b) {
        return a.concat(b);
    });
}
</code>```

Golfed, ES6 (<s>169</s> <s>167</s> <s>119</s> <s>109</s> <s>105</s> <s>89</s> 85 bytes):

```<code>n=>n?[].concat(...[...Array(n)].map((x,i)=>i+1).map(b=>m(n-b).map(a=>[b,...a]))):[[]]
</code>```

答:
J, <s>30</s> 26 bytes

```<code>#&1<@(+/;.1)~2#:@(+i.)@^<:
</code>```

Works by splitting the list of unary n by using the binary values of 2n.

Try it online!

Explanation

```<code>#&1<@(+/;.1)~2#:@(+i.)@^<:  Input: n
                        <:  Decrement n
             2         ^    Compute 2^(n-1)
                 (   )@     Operate on that
                   i.         Make the range [0, 1, ..., 2^(n-1)-1]
                  +           Add 2^(n-1) to each in that range
              #:@           Convert each in that range to binary
#&1                         Make n copies of 1 (n in unary)
     (     )~               Operate over each row on RHS and unary n on LHS
        ;.1                   Chop unary n starting at each 1
      +/                        Reduce by addition on each chop
   <@                           Box the sums of each chop
</code>```

Title: List all ordered partitions of n

Body:
J, <s>30</s> 26 bytes

#&1<@(+/;.1)~2#:@(+i.)@^<:

Works by splitting the list of unary n by using the binary values of 2n.

Try it online!

Explanation

#&1<@(+/;.1)~2#:@(+i.)@^<:  Input: n
                        <:  Decrement n
             2         ^    Compute 2^(n-1)
                 (   )@     Operate on that
                   i.         Make the range [0, 1, ..., 2^(n-1)-1]
                  +           Add 2^(n-1) to each in that range
              #:@           Convert each in that range to binary
#&1                         Make n copies of 1 (n in unary)
     (     )~               Operate over each row on RHS and unary n on LHS
        ;.1                   Chop unary n starting at each 1
      +/                        Reduce by addition on each chop
   <@                           Box the sums of each chop


答:
PHP, 40 Bytes

modified by @user59178 Thank You

```<code><?=max(is_int(0+$i=$argv[1])?18:1.4,$i);
</code>```

PHP, 42 Bytes first Version

```<code><?=max(strpos($i=$argv[1],".")?1.4:18,$i);
</code>```

Title: Yes, of course I'm an adult!

Body:
PHP, 40 Bytes

modified by @user59178 Thank You

<?=max(is_int(0+$i=$argv[1])?18:1.4,$i);

PHP, 42 Bytes first Version

<?=max(strpos($i=$argv[1],".")?1.4:18,$i);


答:
Pyke, 15 bytes

```<code>,16.6*1.4+Qb]Se
</code>```

Try it here!

Takes input in quotes. is_numeric returns 1 if the input doesn't contain a ., otherwise it returns 0

```<code>,16.6*          - 16.6*is_numeric(input)
      1.4+      - ^ + 1.4
          Qb]   - [^, float(input)]
             Se - sorted(^)[-1]
</code>```

Title: Yes, of course I'm an adult!

Body:
Pyke, 15 bytes

,16.6*1.4+Qb]Se

Try it here!

Takes input in quotes. is_numeric returns 1 if the input doesn't contain a ., otherwise it returns 0

,16.6*          - 16.6*is_numeric(input)
      1.4+      - ^ + 1.4
          Qb]   - [^, float(input)]
             Se - sorted(^)[-1]


答:
Pyth, 14 bytes

```<code>eS,@,18h.4}\.`
</code>```

Try it online.

Title: Yes, of course I'm an adult!

Body:
Pyth, 14 bytes

eS,@,18h.4}\.`

Try it online.


答:
JavaScript (ES6), 27 <s>31</s>

Input taken as a string. To check if the input value has decimals, it's appended to itself: if there is no decimal point the result is still a valid number, else it's not. To recognize a valid number (including 0), I use division as in javascript 1/n is numeric and not 0 for any numeric n  (eventually the value is Infinity for n==0), else it's NaN

```<code>x=>x<(y=1/(x+x)?18:1.4)?y:x
</code>```

Test

f=
x=>x<(y=1/(x+x)?18:1.4)?y:x

;[
 ['0', '18' ],['1', '18' ],['2', '18' ],['12', '18' ],['18', '18' ],['43', '43' ],['115', '115'], ['122', '122' ]
,['0.0', '1.4'],['1.0', '1.4'],['1.04', '1.4'],['1.225', '1.4'],['1.399', '1.4'],['1.4', '1.4'],['1.74', '1.74'],['2.0', '2.0'],['2.72', '2.72']
].forEach(t=>{
  var i=t[0],k=t[1],r=f(i)
  console.log(i,k,r,k==r?'OK':'KO')
})```
</div>
</div>
</p>
<p><em>My prev (wrong) solution:</em></p>
<p>Taking input as a number, you can use remainder operator <code>%</code> to check if the number is integer.</p>
```x=>x<(y=x%1?1.4:18)?y:x
```
<p>or</p>
```x=>Math.max(x,x%1?1.4:18)
```

But this does not work as the challenge request to discriminate between, say, 2 and 2.0 and that's the same number. So it's not possibile to get the input as a number

Title: Yes, of course I'm an adult!

Body:
JavaScript (ES6), 27 <s>31</s>

Input taken as a string. To check if the input value has decimals, it's appended to itself: if there is no decimal point the result is still a valid number, else it's not. To recognize a valid number (including 0), I use division as in javascript 1/n is numeric and not 0 for any numeric n  (eventually the value is Infinity for n==0), else it's NaN

x=>x<(y=1/(x+x)?18:1.4)?y:x

Test

f=
x=>x<(y=1/(x+x)?18:1.4)?y:x

;[
 ['0', '18' ],['1', '18' ],['2', '18' ],['12', '18' ],['18', '18' ],['43', '43' ],['115', '115'], ['122', '122' ]
,['0.0', '1.4'],['1.0', '1.4'],['1.04', '1.4'],['1.225', '1.4'],['1.399', '1.4'],['1.4', '1.4'],['1.74', '1.74'],['2.0', '2.0'],['2.72', '2.72']
].forEach(t=>{
  var i=t[0],k=t[1],r=f(i)
  console.log(i,k,r,k==r?'OK':'KO')
})

My prev (wrong) solution:

Taking input as a number, you can use remainder operator % to check if the number is integer.

x=>x<(y=x%1?1.4:18)?y:x

or

x=>Math.max(x,x%1?1.4:18)

But this does not work as the challenge request to discriminate between, say, 2 and 2.0 and that's the same number. So it's not possibile to get the input as a number


答:
JavaScript (ES6), 50 bytes

```<code>n=>[1,...Array(n-1)].reduce((r,_,i)=>r-f(n/++i|0))
</code>```

Port of @Dennis's Python answer.

Title: Compute the Mertens function

Body:
JavaScript (ES6), 50 bytes

n=>[1,...Array(n-1)].reduce((r,_,i)=>r-f(n/++i|0))

Port of @Dennis's Python answer.


答:
C#, 95 Bytes

Golfed:

```<code>string y(string p){int a;return int.TryParse(p,out a)?a>17?p:"18":double.Parse(p)<1.4?"1.4":p;}
</code>```

Ungolfed:

```<code>class YesOfCourseImAnAdult
  {
    public string y(string p)
    {
      int a;
      return int.TryParse(p, out a) ? a > 17 ? p : "18"
       : double.Parse(p) < 1.4 ? "1.4" : p;
    }
  }
</code>```

Test cases:

```<code>var codeGolf = new YesOfCourseImAnAdult();
Console.WriteLine(codeGolf.y("0"));
Console.WriteLine(codeGolf.y("1"));
Console.WriteLine(codeGolf.y("2"));
Console.WriteLine(codeGolf.y("12"));
Console.WriteLine(codeGolf.y("18"));
Console.WriteLine(codeGolf.y("43"));
Console.WriteLine(codeGolf.y("122"));

Console.WriteLine(codeGolf.y("0.0"));
Console.WriteLine(codeGolf.y("1.04"));
Console.WriteLine(codeGolf.y("1.225"));
Console.WriteLine(codeGolf.y("1.399"));
Console.WriteLine(codeGolf.y("1.4"));
Console.WriteLine(codeGolf.y("1.74"));
Console.WriteLine(codeGolf.y("2.0"));
Console.WriteLine(codeGolf.y("2.72"));
</code>```

Output:

```<code>18
18
18
18
18
43
122

1.4
1.4
1.4
1.4
1.4
1.74
2.0
2.72
</code>```

Title: Yes, of course I'm an adult!

Body:
C#, 95 Bytes

Golfed:

string y(string p){int a;return int.TryParse(p,out a)?a>17?p:"18":double.Parse(p)<1.4?"1.4":p;}

Ungolfed:

class YesOfCourseImAnAdult
  {
    public string y(string p)
    {
      int a;
      return int.TryParse(p, out a) ? a > 17 ? p : "18"
       : double.Parse(p) < 1.4 ? "1.4" : p;
    }
  }

Test cases:

var codeGolf = new YesOfCourseImAnAdult();
Console.WriteLine(codeGolf.y("0"));
Console.WriteLine(codeGolf.y("1"));
Console.WriteLine(codeGolf.y("2"));
Console.WriteLine(codeGolf.y("12"));
Console.WriteLine(codeGolf.y("18"));
Console.WriteLine(codeGolf.y("43"));
Console.WriteLine(codeGolf.y("122"));

Console.WriteLine(codeGolf.y("0.0"));
Console.WriteLine(codeGolf.y("1.04"));
Console.WriteLine(codeGolf.y("1.225"));
Console.WriteLine(codeGolf.y("1.399"));
Console.WriteLine(codeGolf.y("1.4"));
Console.WriteLine(codeGolf.y("1.74"));
Console.WriteLine(codeGolf.y("2.0"));
Console.WriteLine(codeGolf.y("2.72"));

Output:

18
18
18
18
18
43
122

1.4
1.4
1.4
1.4
1.4
1.74
2.0
2.72


答:
Brachylog, 14 bytes

```<code>#$:18ot|:1.4ot
</code>```

Try it online!

Explanation

```<code>    #$             Input is an integer
      :18o         Sort the list [Input, 18]
          t        Take the last element
|              Or
    :1.4o          Sort the list [Input, 1.4]
         t         Take the last element
</code>```

Title: Yes, of course I'm an adult!

Body:
Brachylog, 14 bytes

#$:18ot|:1.4ot

Try it online!

Explanation

    #$             Input is an integer
      :18o         Sort the list [Input, 18]
          t        Take the last element
|              Or
    :1.4o          Sort the list [Input, 1.4]
         t         Take the last element


Title: Yes, of course I'm an adult!

Body:
Python 2, 49 bytes

lambda a:(a,1.4)[a<1.4]if"."in`a`else(a,18)[a<18]


答:
Batch, 102 bytes

```<code>@set/ps=
@if %s:.=%==%s% (if %s% lss 18 set s=18)else if %s:~0,1%%s:~2,1% lss 14 set s=1.4
@echo %s%
</code>```

First determines whether the input is an integer by checking whether deleting all .s has any effect on the string. If it is then the value is readily compared against 18, otherwise the first and third characters are combined into a number which is compared against 14.

Title: Yes, of course I'm an adult!

Body:
Batch, 102 bytes

@set/ps=
@if %s:.=%==%s% (if %s% lss 18 set s=18)else if %s:~0,1%%s:~2,1% lss 14 set s=1.4
@echo %s%

First determines whether the input is an integer by checking whether deleting all .s has any effect on the string. If it is then the value is readily compared against 18, otherwise the first and third characters are combined into a number which is compared against 14.


答:
PHP, <s>36</s> <s>35</s> 34 bytes

```<code>echo max($a=$argn,$a[1]&p?1.4:18);
</code>```

Checks whether the character in the second position is a digit (binary and with p). If so, use 18 as the minimum, otherwise 1.4. Then take the bigger of the 2 numbers.

Run like this:

```<code>echo 11 | php -nR 'echo max($a=$argn,$a[1]&p?1.4:18);';echo
</code>```

Explanation

Here's a table of the possible results of the &"p" operation:

```<code>input  binary      &   "p"         result      chr   Truthy/falsy
"."    0010 1110   &   0111 0000   0010 0000   " "   TRUTHY
"0"    0011 0000   &   0111 0000   0011 0000   "0"   FALSY
"1"    0011 0001   &   0111 0000   0011 0000   "0"   FALSY
"2"    0011 0010   &   0111 0000   0011 0000   "0"   FALSY
"3"    0011 0011   &   0111 0000   0011 0000   "0"   FALSY
"4"    0011 0100   &   0111 0000   0011 0000   "0"   FALSY
"5"    0011 0101   &   0111 0000   0011 0000   "0"   FALSY
"6"    0011 0110   &   0111 0000   0011 0000   "0"   FALSY
"7"    0011 0111   &   0111 0000   0011 0000   "0"   FALSY
"8"    0011 1000   &   0111 0000   0011 0000   "0"   FALSY
"9"    0011 1001   &   0111 0000   0011 0000   "0"   FALSY
null   0000 0000   &   0111 0000   0000 0000   0     FALSY
</code>```

When the input is 1 digit, then taking the second digit will result in null. null&"string" will also conveniently evaluate to false. So only when the second char is a . will the expression evaluate to true and 1.4 will be used as the minimum instead of 18.

Tweaks

Saved a byte by using $argn

Title: Yes, of course I'm an adult!

Body:
PHP, <s>36</s> <s>35</s> 34 bytes

echo max($a=$argn,$a[1]&p?1.4:18);

Checks whether the character in the second position is a digit (binary and with p). If so, use 18 as the minimum, otherwise 1.4. Then take the bigger of the 2 numbers.

Run like this:

echo 11 | php -nR 'echo max($a=$argn,$a[1]&p?1.4:18);';echo

Explanation

Here's a table of the possible results of the &"p" operation:

input  binary      &   "p"         result      chr   Truthy/falsy
"."    0010 1110   &   0111 0000   0010 0000   " "   TRUTHY
"0"    0011 0000   &   0111 0000   0011 0000   "0"   FALSY
"1"    0011 0001   &   0111 0000   0011 0000   "0"   FALSY
"2"    0011 0010   &   0111 0000   0011 0000   "0"   FALSY
"3"    0011 0011   &   0111 0000   0011 0000   "0"   FALSY
"4"    0011 0100   &   0111 0000   0011 0000   "0"   FALSY
"5"    0011 0101   &   0111 0000   0011 0000   "0"   FALSY
"6"    0011 0110   &   0111 0000   0011 0000   "0"   FALSY
"7"    0011 0111   &   0111 0000   0011 0000   "0"   FALSY
"8"    0011 1000   &   0111 0000   0011 0000   "0"   FALSY
"9"    0011 1001   &   0111 0000   0011 0000   "0"   FALSY
null   0000 0000   &   0111 0000   0000 0000   0     FALSY

When the input is 1 digit, then taking the second digit will result in null. null&"string" will also conveniently evaluate to false. So only when the second char is a . will the expression evaluate to true and 1.4 will be used as the minimum instead of 18.

Tweaks

Saved a byte by using $argn


答:
CJam, <s>18</s> 14 bytes

Saved 4 bytes thanks to Martin Ender.

```<code>q~_`'.&1.4I?e>
</code>```

Online interpreter

Title: Yes, of course I'm an adult!

Body:
CJam, <s>18</s> 14 bytes

Saved 4 bytes thanks to Martin Ender.

q~_`'.&1.4I?e>

Online interpreter


答:
IBM/Lotus Notes Formula Language, <s>58</s> 49 bytes

```<code>@If(@Like(@Text(a);"%.%");@If(a<1.4;1.4;a);@If(a<18;18;a))
</code>```

Computed field formula where a is an editable numeric field.

EDIT

```<code>@If(@Like(@Text(a);"%.%");@Max(1.4;a);@Max(18;a))
</code>```

Alternative inspired by @Mego

Title: Yes, of course I'm an adult!

Body:
I think we've all done this as a kid: some websites require a minimum age of 18, so we just subtract a few years from the year of birth and voilà, we 'are' 18+.

In addition, for most rides at amusement parks the minimum height to enter is 1.40 meters (here in The Netherlands it as at least). Of course this can be cheated less easily than age, but you could wear shoes with thick heels, put your hair up, wear a hat, stand on your toes, etc.

Input:

Your program/function accepts a positive integer or decimal.

Output:

Is the input an integer >= 18? Simply print the input.

Is the input an integer 0-17? Print 18.

Is the input a decimal >= 1.4? Simply print the input.

Is the input a decimal 0.0-1.4? Print 1.4.

Challenge rules:

Assume the input will always be in the range of 0-122 (oldest woman ever was 122) or 0.0-2.72 (tallest man ever was 2.72).

You are allowed to take the input as a String, object, or anything else you prefer.

The decimal inputs will never have more than three decimal places after the decimal point.

2 or 2. both aren't valid outputs for 2.0. You are free to output 2.00 or 2.000 instead of 2.0 however.

Just like the input the output will never have more than three decimal places after the point.

General rules:

This is code-golf, so shortest answer in bytes wins.

Don't let code-golf languages discourage you from posting answers with non-codegolfing languages. Try to come up with an as short as possible answer for 'any' programming language.

Standard rules apply for your answer, so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters, full programs. Your call.

Default Loopholes are forbidden.

If possible, please add a link with a test for your code.

Also, please add an explanation if necessary.

Test cases:

```<code>0      ->  18
1      ->  18
2      ->  18
12     ->  18
18     ->  18
43     ->  43
115    ->  115
122    ->  122

0.0    ->  1.4
1.04   ->  1.4
1.225  ->  1.4
1.399  ->  1.4
1.4    ->  1.4
1.74   ->  1.74
2.0    ->  2.0
2.72   ->  2.72
</code>```

Body:
IBM/Lotus Notes Formula Language, <s>58</s> 49 bytes

@If(@Like(@Text(a);"%.%");@If(a<1.4;1.4;a);@If(a<18;18;a))

Computed field formula where a is an editable numeric field.

EDIT

@If(@Like(@Text(a);"%.%");@Max(1.4;a);@Max(18;a))

Alternative inspired by @Mego


答:
C#, 69 bytes

```<code>s=>s.Contains(".")?float.Parse(s)<1.4?"1.4":s:int.Parse(s)<18?"18":s;
</code>```

Try it online!

Full program with test cases:

```<code>using System;

namespace YesImAnAdult
{
    class Program
    {
        static void Main(string[] args)
        {
            Func<string,string>f= s=>s.Contains(".")?float.Parse(s)<1.4?"1.4":s:int.Parse(s)<18?"18":s;

            Console.WriteLine(f("0"));  //18
            Console.WriteLine(f("1"));  //18
            Console.WriteLine(f("2"));  //18
            Console.WriteLine(f("12")); //18
            Console.WriteLine(f("18")); //18
            Console.WriteLine(f("43")); //43
            Console.WriteLine(f("122"));    //122

            Console.WriteLine(f("0.0"));    //1.4
            Console.WriteLine(f("1.04"));   //1.4
            Console.WriteLine(f("1.225"));  //1.4
            Console.WriteLine(f("1.399"));  //1.4
            Console.WriteLine(f("1.4"));    //1.4
            Console.WriteLine(f("1.74"));   //1.74
            Console.WriteLine(f("2.0"));    //2.0
            Console.WriteLine(f("2.72"));   //2.72
        }
    }
}
</code>```

A pretty straightforward solution. Note that on some systems float.Parse() might return incorrect results. Pass CultureInfo.InvariantCulture as the second argument according to this answer.

Title: Yes, of course I'm an adult!

Body:
C#, 69 bytes

s=>s.Contains(".")?float.Parse(s)<1.4?"1.4":s:int.Parse(s)<18?"18":s;

Try it online!

Full program with test cases:

using System;

namespace YesImAnAdult
{
    class Program
    {
        static void Main(string[] args)
        {
            Func<string,string>f= s=>s.Contains(".")?float.Parse(s)<1.4?"1.4":s:int.Parse(s)<18?"18":s;

            Console.WriteLine(f("0"));  //18
            Console.WriteLine(f("1"));  //18
            Console.WriteLine(f("2"));  //18
            Console.WriteLine(f("12")); //18
            Console.WriteLine(f("18")); //18
            Console.WriteLine(f("43")); //43
            Console.WriteLine(f("122"));    //122

            Console.WriteLine(f("0.0"));    //1.4
            Console.WriteLine(f("1.04"));   //1.4
            Console.WriteLine(f("1.225"));  //1.4
            Console.WriteLine(f("1.399"));  //1.4
            Console.WriteLine(f("1.4"));    //1.4
            Console.WriteLine(f("1.74"));   //1.74
            Console.WriteLine(f("2.0"));    //2.0
            Console.WriteLine(f("2.72"));   //2.72
        }
    }
}

A pretty straightforward solution. Note that on some systems float.Parse() might return incorrect results. Pass CultureInfo.InvariantCulture as the second argument according to this answer.


答:
Jelly, <s>16 15 13</s> 12 bytes

-1 thanks to caird coinheringaahing (take input as a string).

```<code>ċ”.ị1.4,18»V
</code>```

TryItOnline

Or see all test cases, also at TryItOnline

How?

```<code>ċ”.ị1.4,18»V - Main link: string, S
 ”.          - '.' character
ċ            - count (occurrences of '.' in S)
    1.4,18   - pair literals 1.4 and 18:  [1.4,  18]
   ị         - index into (1-indexed)
           V - evaluate (S) as Jelly code
          »  - maximum
</code>```

Title: Yes, of course I'm an adult!

Body:
Jelly, <s>16 15 13</s> 12 bytes

-1 thanks to caird coinheringaahing (take input as a string).

ċ”.ị1.4,18»V

TryItOnline

Or see all test cases, also at TryItOnline

How?

ċ”.ị1.4,18»V - Main link: string, S
 ”.          - '.' character
ċ            - count (occurrences of '.' in S)
    1.4,18   - pair literals 1.4 and 18:  [1.4,  18]
   ị         - index into (1-indexed)
           V - evaluate (S) as Jelly code
          »  - maximum


答:
Perl, <s>29</s> 27 bytes

Includes +2 for -lp

Give input on STDIN

```<code>adult.pl <<< 1.24
</code>```

adult.pl:

```<code>#!/usr/bin/perl -lp
$_>($a=/\./?1.4:18)or*_=a
</code>```

If you don't mind an extra newline if you really were a full adult then leaving out the l option for 26 bytes works too

Title: Yes, of course I'm an adult!

Body:
Perl, <s>29</s> 27 bytes

Includes +2 for -lp

Give input on STDIN

adult.pl <<< 1.24

adult.pl:

#!/usr/bin/perl -lp
$_>($a=/\./?1.4:18)or*_=a

If you don't mind an extra newline if you really were a full adult then leaving out the l option for 26 bytes works too


答:
Actually, 16 bytes

```<code>;:.7τ9τ($'.íuIkM
</code>```

Try it online!

Explanation:

```<code>;:.7τ9τ($'.íuIkM
;                 dupe input
 :.7τ             1.4 (.7*2) - note that :1.4 is the same length, but an additional delimiter would be needed to separate it from the following 1
     9τ           18 (9*2)
       ($'.íu     1-based index of "." in string representation of input, 0 if not found
             I    1.4 if input contains a "." else 18
              kM  maximum of remaining values on stack
</code>```

Title: Yes, of course I'm an adult!

Body:
Actually, 16 bytes

;:.7τ9τ($'.íuIkM

Try it online!

Explanation:

;:.7τ9τ($'.íuIkM
;                 dupe input
 :.7τ             1.4 (.7*2) - note that :1.4 is the same length, but an additional delimiter would be needed to separate it from the following 1
     9τ           18 (9*2)
       ($'.íu     1-based index of "." in string representation of input, 0 if not found
             I    1.4 if input contains a "." else 18
              kM  maximum of remaining values on stack


答:
<s>Dyalog APL, 14 bytes</s> Rendered invalid by further specifications

⎕IO←0 which is default on many systems. Takes string as argument.

⍎⌈18 1.4⊃⍨'.'∘∊
```

⍎⌈ max of the evaluated argument and

18 1.4⊃⍨ {18,1.4} selected by

'.'∘∊ whether the argument contains a period

Title: Yes, of course I'm an adult!

Body:
<s>Dyalog APL, 14 bytes</s> Rendered invalid by further specifications

⎕IO←0 which is default on many systems. Takes string as argument.

⍎⌈18 1.4⊃⍨'.'∘∊

⍎⌈ max of the evaluated argument and

18 1.4⊃⍨ {18,1.4} selected by

'.'∘∊ whether the argument contains a period


问:
Multiple-Key Sorting
Given a list of indices and zero or more lists of integers, output the lists of integers, sorted in ascending order, with the key priority from the first input.

Example

Let the keys input be [1, 0, 2], and the lists input be [[5, 3, 4], [6, 2, 1], [5, 2, 1]]. Those lists need to be sorted by their second element, then first element, then third element, in ascending order:

First, we sort by the values at index 1: [[6, 2, 1], [5, 2, 1], [5, 3, 4]]

Next, we break any ties from the first sort using the values at index 0: [[5, 2, 1], [6, 2, 1], [5, 3, 4]]

Finally, we break any remaining ties with the vlues at index 2 (this doesn't actually change anything, because there are no ties remaining).

Details

Sorting is stable: if two elements compare equal with respect to the given sort keys, they must remain in the same relative order in the output. For example, if A and B are equal under the given sort keys, and the input was [..., A, ..., B, ...], A must be placed before B in the output.

A sort key will never reference a non-existant element in one of the input lists.

No sort key will be repeated. Thus, [1, 2, 1] is not a valid list of sort keys.

Any elements not referenced by the sort keys do not factor into the sorting order. Only the initial relative order and the values of the elements referenced by the sort keys determine the output order.

You may choose whether the sort keys are zero-indexed or one-indexed.

There will be no negative values in the sort keys. If you choose to use one-indexing, there will be no zeroes in the sort keys either.

Integer values will not exceed your language's natively-representable range. If your chosen language is natively capable of arbitrary-precision integers (like Python), then any integer value can be present in the input, subject to memory constraints.

Reference Implementation (Python 2)

#!/usr/bin/env python

keys = input()
lists = input()

print sorted(lists, key=lambda l:[l[x] for x in keys])
```
<p>Try it online</p>
<h2>Test Cases</h2>
<p>Format: <code>keys lists -> output</code>. All sort keys are zero-indexed.</p>
```[1, 0, 2] [[5, 3, 4], [6, 2, 1], [5, 2, 1]] -> [[5, 2, 1], [6, 2, 1], [5, 3, 4]]
[1, 2] [[5, 3, 4], [6, 2, 1], [5, 2, 1]] -> [[6, 2, 1], [5, 2, 1], [5, 3, 4]]
[0, 1] [[1, 2], [2, 1]] -> [[1, 2], [2, 1]]
[1, 0] [[1, 2], [2, 1]] -> [[2, 1], [1, 2]]
[0] [[4], [10, 11, -88], [-2, 7]] -> [[-2, 7], [4], [10, 11, -88]]
[2] [[-1, -5, 8, -1, -4, -10, -5, 4, 4, 6, -8, 4, 2], [-7, 6, 2, -8, -7, 7, -3, 3, 0, -6, 1], [-9, 8, -5, -1, -7, -8, -5, -6, 5, -6, 6]] -> [[-9, 8, -5, -1, -7, -8, -5, -6, 5, -6, 6], [-7, 6, 2, -8, -7, 7, -3, 3, 0, -6, 1], [-1, -5, 8, -1, -4, -10, -5, 4, 4, 6, -8, 4, 2]]
[2, 1] [[9, 2, -2, -10, -6], [3, -4, -2]] -> [[3, -4, -2], [9, 2, -2, -10, -6]]
[2, 4, 8] [[5, -3, 4, -6, -1, -2, -2, -4, 5], [-2, -3, 6, -4, -1, -4, -4, -5, 8, 9, 9, -3, 3, -9, -3], [2, 0, 10, -10, -1, 2, -1, 5, -1, 10, -5], [-7, -8, -6, 7, 3, 8, 6, -7, -2, 0, -6, -4, 4, -3, 2, -3]] -> [[-7, -8, -6, 7, 3, 8, 6, -7, -2, 0, -6, -4, 4, -3, 2, -3], [5, -3, 4, -6, -1, -2, -2, -4, 5], [-2, -3, 6, -4, -1, -4, -4, -5, 8, 9, 9, -3, 3, -9, -3], [2, 0, 10, -10, -1, 2, -1, 5, -1, 10, -5]]
[1, 2, 3, 4, 5] [[-7, 3, -8, 3, 5, -1, 6, -6, 9, 8], [-9, -1, -7, -9, -10, -2, -8, -10, -10, -3], [5, 3, -6, -5, -4, -4, -8, 2], [9, -4, 1, -1, -3, -2], [-6, -10, 4, -10, 6, 6, -1, 3, 0, 0], [1, -2, -7, -6, -7, -7, -1, 0, -4, 3, 3], [7, -1, -7, 2, -2, 9, 7, 5, -6, -8], [1, -5, -3, -10, -7, 9, -8, -5, -1], [-9, 4, -1, -1, 2, 4]] -> [[-6, -10, 4, -10, 6, 6, -1, 3, 0, 0], [1, -5, -3, -10, -7, 9, -8, -5, -1], [9, -4, 1, -1, -3, -2], [1, -2, -7, -6, -7, -7, -1, 0, -4, 3, 3], [-9, -1, -7, -9, -10, -2, -8, -10, -10, -3], [7, -1, -7, 2, -2, 9, 7, 5, -6, -8], [-7, 3, -8, 3, 5, -1, 6, -6, 9, 8], [5, 3, -6, -5, -4, -4, -8, 2], [-9, 4, -1, -1, 2, 4]]
[8, 7, 3, 2, 4, 9, 1] [[8, -5, 1, -6, -1, -4, 6, 10, 10, 6, 9, 5], [4, -8, 6, -10, -2, -3, 2, -6, 9, 5, 4, 10, 2, 3], [10, -1, 3, 0, -4, 1, -5, -4, -1, -7, 9, -9, -1, -5, 7, 8, 9, 6, -3], [0, -9, -7, -2, 2, -5, 7, 4, 6, -4, 1, 8, -7, 10], [5, 6, -9, 0, -1, 5, 4, 7, 5, 10, 2, 5, 7, -9]] -> [[10, -1, 3, 0, -4, 1, -5, -4, -1, -7, 9, -9, -1, -5, 7, 8, 9, 6, -3], [5, 6, -9, 0, -1, 5, 4, 7, 5, 10, 2, 5, 7, -9], [0, -9, -7, -2, 2, -5, 7, 4, 6, -4, 1, 8, -7, 10], [4, -8, 6, -10, -2, -3, 2, -6, 9, 5, 4, 10, 2, 3], [8, -5, 1, -6, -1, -4, 6, 10, 10, 6, 9, 5]]
```

答:
Python, 50 bytes

lambda l,k:sorted(l,key=lambda x:[x[y]for y in k])
```

This is a trivially-golfed version of the reference implementation. l is the lists parameter, and k is the sort keys parameter. l can be any iterable, so long as its elements are subscriptable by integers (like lists, tuples, or int-keyed dicts). k can be any iterable.

Title: Multiple-Key Sorting

Body:
Python, 50 bytes

lambda l,k:sorted(l,key=lambda x:[x[y]for y in k])

This is a trivially-golfed version of the reference implementation. l is the lists parameter, and k is the sort keys parameter. l can be any iterable, so long as its elements are subscriptable by integers (like lists, tuples, or int-keyed dicts). k can be any iterable.


答:
CJam, 13 bytes

```<code>{W%{{X=}$}fX}
</code>```

An unnamed block which expects the list of lists and the list of priorities on top of the stack and replaces them with the sorted list of lists.

Try it online! (As a test suite.)

Explanation

Sorting with tie breakers can be implemented by repeatedly sorting the entire list stably going from the lowest-priority key to the highest-priority key.

```<code>W%      e# Reverse priority list.
{       e# For each priority X...
  {     e#   Sort the lists by the result of this block...
    X=  e#     Extract the Xth element from the current list.
  }$
}fX
</code>```

Title: Multiple-Key Sorting

Body:
Given a list of indices and zero or more lists of integers, output the lists of integers, sorted in ascending order, with the key priority from the first input.

Example

Let the keys input be [1, 0, 2], and the lists input be [[5, 3, 4], [6, 2, 1], [5, 2, 1]]. Those lists need to be sorted by their second element, then first element, then third element, in ascending order:

First, we sort by the values at index 1: [[6, 2, 1], [5, 2, 1], [5, 3, 4]]

Next, we break any ties from the first sort using the values at index 0: [[5, 2, 1], [6, 2, 1], [5, 3, 4]]

Finally, we break any remaining ties with the vlues at index 2 (this doesn't actually change anything, because there are no ties remaining).

Details

Sorting is stable: if two elements compare equal with respect to the given sort keys, they must remain in the same relative order in the output. For example, if A and B are equal under the given sort keys, and the input was [..., A, ..., B, ...], A must be placed before B in the output.

A sort key will never reference a non-existant element in one of the input lists.

No sort key will be repeated. Thus, [1, 2, 1] is not a valid list of sort keys.

Any elements not referenced by the sort keys do not factor into the sorting order. Only the initial relative order and the values of the elements referenced by the sort keys determine the output order.

You may choose whether the sort keys are zero-indexed or one-indexed.

There will be no negative values in the sort keys. If you choose to use one-indexing, there will be no zeroes in the sort keys either.

Integer values will not exceed your language's natively-representable range. If your chosen language is natively capable of arbitrary-precision integers (like Python), then any integer value can be present in the input, subject to memory constraints.

Reference Implementation (Python 2)

#!/usr/bin/env python

keys = input()
lists = input()

print sorted(lists, key=lambda l:[l[x] for x in keys])
```
<p>Try it online</p>
<h2>Test Cases</h2>
<p>Format: <code>keys lists -> output</code>. All sort keys are zero-indexed.</p>
```[1, 0, 2] [[5, 3, 4], [6, 2, 1], [5, 2, 1]] -> [[5, 2, 1], [6, 2, 1], [5, 3, 4]]
[1, 2] [[5, 3, 4], [6, 2, 1], [5, 2, 1]] -> [[6, 2, 1], [5, 2, 1], [5, 3, 4]]
[0, 1] [[1, 2], [2, 1]] -> [[1, 2], [2, 1]]
[1, 0] [[1, 2], [2, 1]] -> [[2, 1], [1, 2]]
[0] [[4], [10, 11, -88], [-2, 7]] -> [[-2, 7], [4], [10, 11, -88]]
[2] [[-1, -5, 8, -1, -4, -10, -5, 4, 4, 6, -8, 4, 2], [-7, 6, 2, -8, -7, 7, -3, 3, 0, -6, 1], [-9, 8, -5, -1, -7, -8, -5, -6, 5, -6, 6]] -> [[-9, 8, -5, -1, -7, -8, -5, -6, 5, -6, 6], [-7, 6, 2, -8, -7, 7, -3, 3, 0, -6, 1], [-1, -5, 8, -1, -4, -10, -5, 4, 4, 6, -8, 4, 2]]
[2, 1] [[9, 2, -2, -10, -6], [3, -4, -2]] -> [[3, -4, -2], [9, 2, -2, -10, -6]]
[2, 4, 8] [[5, -3, 4, -6, -1, -2, -2, -4, 5], [-2, -3, 6, -4, -1, -4, -4, -5, 8, 9, 9, -3, 3, -9, -3], [2, 0, 10, -10, -1, 2, -1, 5, -1, 10, -5], [-7, -8, -6, 7, 3, 8, 6, -7, -2, 0, -6, -4, 4, -3, 2, -3]] -> [[-7, -8, -6, 7, 3, 8, 6, -7, -2, 0, -6, -4, 4, -3, 2, -3], [5, -3, 4, -6, -1, -2, -2, -4, 5], [-2, -3, 6, -4, -1, -4, -4, -5, 8, 9, 9, -3, 3, -9, -3], [2, 0, 10, -10, -1, 2, -1, 5, -1, 10, -5]]
[1, 2, 3, 4, 5] [[-7, 3, -8, 3, 5, -1, 6, -6, 9, 8], [-9, -1, -7, -9, -10, -2, -8, -10, -10, -3], [5, 3, -6, -5, -4, -4, -8, 2], [9, -4, 1, -1, -3, -2], [-6, -10, 4, -10, 6, 6, -1, 3, 0, 0], [1, -2, -7, -6, -7, -7, -1, 0, -4, 3, 3], [7, -1, -7, 2, -2, 9, 7, 5, -6, -8], [1, -5, -3, -10, -7, 9, -8, -5, -1], [-9, 4, -1, -1, 2, 4]] -> [[-6, -10, 4, -10, 6, 6, -1, 3, 0, 0], [1, -5, -3, -10, -7, 9, -8, -5, -1], [9, -4, 1, -1, -3, -2], [1, -2, -7, -6, -7, -7, -1, 0, -4, 3, 3], [-9, -1, -7, -9, -10, -2, -8, -10, -10, -3], [7, -1, -7, 2, -2, 9, 7, 5, -6, -8], [-7, 3, -8, 3, 5, -1, 6, -6, 9, 8], [5, 3, -6, -5, -4, -4, -8, 2], [-9, 4, -1, -1, 2, 4]]
[8, 7, 3, 2, 4, 9, 1] [[8, -5, 1, -6, -1, -4, 6, 10, 10, 6, 9, 5], [4, -8, 6, -10, -2, -3, 2, -6, 9, 5, 4, 10, 2, 3], [10, -1, 3, 0, -4, 1, -5, -4, -1, -7, 9, -9, -1, -5, 7, 8, 9, 6, -3], [0, -9, -7, -2, 2, -5, 7, 4, 6, -4, 1, 8, -7, 10], [5, 6, -9, 0, -1, 5, 4, 7, 5, 10, 2, 5, 7, -9]] -> [[10, -1, 3, 0, -4, 1, -5, -4, -1, -7, 9, -9, -1, -5, 7, 8, 9, 6, -3], [5, 6, -9, 0, -1, 5, 4, 7, 5, 10, 2, 5, 7, -9], [0, -9, -7, -2, 2, -5, 7, 4, 6, -4, 1, 8, -7, 10], [4, -8, 6, -10, -2, -3, 2, -6, 9, 5, 4, 10, 2, 3], [8, -5, 1, -6, -1, -4, 6, 10, 10, 6, 9, 5]]
```

Body:
CJam, 13 bytes

{W%{{X=}$}fX}

An unnamed block which expects the list of lists and the list of priorities on top of the stack and replaces them with the sorted list of lists.

<a href="http://cjam.tryitonline.net/#code=cU4ve35cCgp7VyV7e1g9fSR9Zlh9Cgp-cH0v&input=WzEgMCAyXSBbWzUgMyA0XSBbNiAyIDFdIFs1IDIgMV1dClsxIDJdIFtbNSAzIDRdIFs2IDIgMV0gWzUgMiAxXV0KWzBdIFtbNF0gWzEwIDExIC04OF0gWy0yIDddXQpbMCAxXSBbWzEgMl0gWzIgMV1dClsxIDBdIFtbMSAyXSBbMiAxXV0gClsyXSBbWy0xIC01IDggLTEgLTQgLTEwIC01IDQgNCA2IC04IDQgMl0gWy03IDYgMiAtOCAtNyA3IC0zIDMgMCAtNiAxXSBbLTkgOCAtNSAtMSAtNyAtOCAtNSAtNiA1IC02IDZdXQpbMiAxXSBbWzkgMiAtMiAtMTAgLTZdIFszIC00IC0yXV0KWzIgNCA4XSBbWzUgLTMgNCAtNiAtMSAtMiAtMiAtNCA1XSBbLTIgLTMgNiAtNCAtMSAtNCAtNCAtNSA4IDkgOSAtMyAzIC05IC0zXSBbMiAwIDEwIC0xMCAtMSAyIC0xIDUgLTEgMTAgLTVdIFstNyAtOCAtNiA3IDMgOCA2IC03IC0yIDAgLTYgLTQgNCAtMyAyIC0zXV0KWzEgMiAzIDQgNV0gW1stNyAzIC04IDMgNSAtMSA2IC02IDkgOF0gWy05IC0xIC03IC05IC0xMCAtMiAtOCAtMTAgLTEwIC0zXSBbNSAzIC02IC01IC00IC00IC04IDJdIFs5IC00IDEgLTEgLTMgLTJdIFstNiAtMTAgNCAtMTAgNiA2IC0xIDMgMCAwXSBbMSAtMiAtNyAtNiAtNyAtNyAtMSAwIC00IDMgM10gWzcgLTEgLTcgMiAtMiA5IDcgNSAtNiAtOF0gWzEgLTUgLTMgLTEwIC03IDkgLTggLTUgLTFdIFstOSA0IC0xIC0xIDIgNF1dCls4IDcgMyAyIDQgOSAxXSBbWzggLTUgMSAtNiAtMSAtNCA2IDEwIDEwIDYgOSA1XSBbNCAtOCA2IC0xMCAtMiAtMyAyIC02IDkgNSA0IDEwIDIgM10gWzEwIC0xIDMgMCAtNCAxIC01IC00IC0xIC03IDkgLTkgLTEgLTUgNyA4IDkgNiAtM10gWzAgLTkgLTcgLTIgMiAtNSA3IDQgNiAtNCAxIDggLTcgMTBdIFs1IDYgLTkgMCAtMSA1IDQgNyA1IDEwIDIgNSA3IC05XV0">Try it online! (As a test suite.)

Explanation

Sorting with tie breakers can be implemented by repeatedly sorting the entire list stably going from the lowest-priority key to the highest-priority key.

W%      e# Reverse priority list.
{       e# For each priority X...
  {     e#   Sort the lists by the result of this block...
    X=  e#     Extract the Xth element from the current list.
  }$
}fX


问:
Convert pointfree to pointful
Being a Haskell hacker, I prefer pointfree notation over pointful. Unfortunately some people find pointfree notation hard to read, and I find it hard to get the correct number of parentheses when I write in pointful.
Help me convert code written in pointfree to pointful notation!

About

In pointfree notation we use points (yes, really) to feed the output of one function into another. Say, if you had a function succ that takes a number and adds 1 to it, and you wanted to make a function that adds 3 to a number, instead of doing this:

```<code>\x -> succ(succ(succ(x)))
</code>```

you could do this:

```<code>succ.succ.succ
</code>```

Pointfree only works with functions that take a single parameter however (in this challenge anyway), so if our function wasn't succ but rather add which take 2 numbers and adds them together, we would have to feed it arguments until there is only one left:

```<code>pointful:  \x -> add 1(add 1(add 1 x))
pointfree: add 1 . add 1 . add 1
</code>```

Lastly, functions may take other functions as arguments:

```<code>Pointfree: map (f a . f b) . id
Pointful:  \x -> map (\x -> f a (f b x)) (id x)

Javascript equivalent: x => map (x => f(a,f(b,x)), id(x))
</code>```

Input and expected output

```<code>f . f . f
\x -> f (f (f x))

f a . f b . f c
\x -> f a (f b (f c x))

f (f a . f b) . f c
\x -> f (\x -> f a (f b x)) (f c x)

a b c . d e . f g h i . j k l . m
\x -> a b c (d e (f g h i (j k l (m x))))

a.b(c.d)e.f g(h)(i j.k).l(m(n.o).p)
\x->a(b(\y->c(d y))e(f g h(\z->i j(k z))(l(\q->m(\w->n(o w))(p q))x)))
</code>```

Rules

Your output may have more spaces or parentheses than required, as long as they are balanced

You don't have to make sure that the name of the variable you create \x isn't already used somewhere else in the code

It is your choice whether to create a function or a full program

This is codegolf, shortest code in bytes win!

You might find blunt useful, it converts between the two notations (but also factorizes the code when possible): https://blunt.herokuapp.com

Title: Convert pointfree to pointful

Body:
Haskell, <s>402</s> 289 bytes

Quite long, but I think it works..

(!)=elem
n%'('=n+1
n%')'=n-1
n%_=n
a?n=a!"."&&n<1
a#n=a!" ("&&n<1||a!")"&&n<2
q a='(':a++")"
p s o n[]=[s]
p s o n(a:b)|o a n=[t|t@(q:r)<-s:p""o(n%a)b]|0<1=p(s++[a])o(n%a)b
k=foldr((++).(++" ").f)"".p""(#)0
f t|not$any(!"(. ")t=t|l@(x:r)<-p""(?)0t=q$"\\x->"++foldr((.q).(++).k)"x"l|0<1=k t


答:
Brachylog, 29 bytes

```<code>tT,?hg:Tz:{:2f}o:ta
heI,?t:Im
</code>```

Try it online!

Explanation

We use the fact that o - Order can be used with an additionnal predicate as input: we order the lists by using for each [Keys, a list] the list of the elements of a list which are at index a key in the order that they appear in Keys.

```<code>                          Input = [Keys, List of lists]

tT,                       Call the Keys T
   ?hg:T                  Create the list [[T], List of lists]
        z                 Zip [T] with the list of lists
         :{   }o          Order by the output of this predicate
                :ta       Keep only the last element of each sublist in the Output

           :2f            Find all outputs of the predicate below

heI,                      Take a key I
    ?t:Im                 Output is the Ith element of the sublist
</code>```

Title: Multiple-Key Sorting

Body:
Brachylog, 29 bytes

tT,?hg:Tz:{:2f}o:ta
heI,?t:Im

Try it online!

Explanation

We use the fact that o - Order can be used with an additionnal predicate as input: we order the lists by using for each [Keys, a list] the list of the elements of a list which are at index a key in the order that they appear in Keys.

                          Input = [Keys, List of lists]

tT,                       Call the Keys T
   ?hg:T                  Create the list [[T], List of lists]
        z                 Zip [T] with the list of lists
         :{   }o          Order by the output of this predicate
                :ta       Keep only the last element of each sublist in the Output

           :2f            Find all outputs of the predicate below

heI,                      Take a key I
    ?t:Im                 Output is the Ith element of the sublist


Title: Yes, of course I'm an adult!

Body:
Racket 76 bytes

(λ(n)(cond[(integer? n)(if(>= n 18)n 18)][(number? n)(if(>= n 1.4)n 1.4)]))

Ungolfed version:

(define f
  (λ(n)
    (cond
      [(integer? n) (if(>= n 18) n 18)]
      [(number? n) (if(>= n 1.4) n 1.4)]
      )))

Testing:

(f 1.3)
(f 15)
(f 19)
(f 1.5)

Output:

1.4
18
19
1.5


答:
GNU sed, 40 + 1 = 41 bytes

(score +1 for use of -r flag to interpreter)

```<code>s/^.$|^1[^9]$/18/
/^0|1\.[0-3]/s/.*/1.4/
</code>```

Annotated:

#!/bin/sed -rf

# First, anything that's a single digit or is '1' followed by a
# digit other than '9' is replaced with '18'.
s/^.$|^1[^9]$/18/

# Now, any line beginning with '0' or containing '1.0' to '1.3' is
# replaced with '1.4'.
/^0|1\.[0-3]/s/.*/1.4/
```

<p>We take advantage of the constraints on input, so don't have to test the start of string when we see '1.' - we know there's only one digit before the decimal point.</p>

<h3>Test result:</h3>

```$ ./94832.sed <<END
> 0
> 1
> 2
> 12
> 18
> 43
> 122
>
> 0.0
> 1.04
> 1.225
> 1.399
> 1.4
> 1.74
> 2.0
> 2.72
> END
18
18
18
18
18
43
122

1.4
1.4
1.4
1.4
1.4
1.74
2.0
2.72
```

Title: Yes, of course I'm an adult!

Body:
GNU sed, 40 + 1 = 41 bytes

(score +1 for use of -r flag to interpreter)

s/^.$|^1[^9]$/18/
/^0|1\.[0-3]/s/.*/1.4/

Annotated:

#!/bin/sed -rf

# First, anything that's a single digit or is '1' followed by a
# digit other than '9' is replaced with '18'.
s/^.$|^1[^9]$/18/

# Now, any line beginning with '0' or containing '1.0' to '1.3' is
# replaced with '1.4'.
/^0|1\.[0-3]/s/.*/1.4/

We take advantage of the constraints on input, so don't have to test the start of string when we see '1.' - we know there's only one digit before the decimal point.

Test result:

$ ./94832.sed <<END
> 0
> 1
> 2
> 12
> 18
> 43
> 122
>
> 0.0
> 1.04
> 1.225
> 1.399
> 1.4
> 1.74
> 2.0
> 2.72
> END
18
18
18
18
18
43
122

1.4
1.4
1.4
1.4
1.4
1.74
2.0
2.72


答:
Mathematica, <s>22</s> 19 bytes

```<code>SortBy[Extract/@#]&
</code>```

Uses 1-based indices. This unnamed function is curried, so the calling convention is:

```<code>SortBy[Extract/@#]&[{2, 1, 3}][{{5, 3, 4}, {6, 2, 1}, {5, 2, 1}}]
</code>```

Mathematica's SortBy can take a list of functions in which case the individual functions are used as successive tie-breakers, so that's just what we want. All we need to do is create a list of functions which return the corresponding list element. This can be done with Extract. Extract is normally a binary function Extract[list, index] which returns a list element. However if used unarily, then Extract[index] returns a function which retrieves the element at index from a list passed to it. In other words, the index parameter of Extract can be curried. We make use of this by mapping Extract over the list of indices we're given, which creates the list of functions we need.

Title: Multiple-Key Sorting

Body:
Mathematica, <s>22</s> 19 bytes

SortBy[Extract/@#]&

Uses 1-based indices. This unnamed function is curried, so the calling convention is:

SortBy[Extract/@#]&[{2, 1, 3}][{{5, 3, 4}, {6, 2, 1}, {5, 2, 1}}]

Mathematica's SortBy can take a list of functions in which case the individual functions are used as successive tie-breakers, so that's just what we want. All we need to do is create a list of functions which return the corresponding list element. This can be done with Extract. Extract is normally a binary function Extract[list, index] which returns a list element. However if used unarily, then Extract[index] returns a function which retrieves the element at index from a list passed to it. In other words, the index parameter of Extract can be curried. We make use of this by mapping Extract over the list of indices we're given, which creates the list of functions we need.


答:
Jelly, 4 bytes

```<code>⁴ị$Þ
</code>```

Try it online!

Title: Multiple-Key Sorting

Body:
Jelly, 4 bytes

⁴ị$Þ

Try it online!


答:
EXCEL: <s>26</s> <s>31</s> 29 Bytes

```<code>=MAX(A1;IF(MOD(A1;1);1,4;18))
</code>```

Formula can go anywhere except A1, the input cell.

Fixed errors, and replaced with Emigna's suggestion.

Thanks to Alexandru for saving me some bytes using truths

Title: Yes, of course I'm an adult!

Body:
EXCEL: <s>26</s> <s>31</s> 29 Bytes

=MAX(A1;IF(MOD(A1;1);1,4;18))

Formula can go anywhere except A1, the input cell.

Fixed errors, and replaced with Emigna's suggestion.

Thanks to Alexandru for saving me some bytes using truths


答:
PHP: 40 bytes

```<code>$i=is_int($i)?$i>17?$i:18:$i>1.4?$i:1.4;
</code>```

psuedocode, (nested turnary) :

```<code>if (i is an integer) then
  if (i is bigger than 17) then i=18 else i=i
otherwise (its a decimal)
  if (i is bigger than 1.4) then i=i else i=1.4
end if
</code>```

Title: Yes, of course I'm an adult!

Body:
PHP: 40 bytes

$i=is_int($i)?$i>17?$i:18:$i>1.4?$i:1.4;

psuedocode, (nested turnary) :

if (i is an integer) then
  if (i is bigger than 17) then i=18 else i=i
otherwise (its a decimal)
  if (i is bigger than 1.4) then i=i else i=1.4
end if


答:
Ruby, 35 bytes

```<code>->k,a{a.sort_by{|e|e.values_at *k}}
</code>```

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

Title: Multiple-Key Sorting

Body:
Ruby, 35 bytes

->k,a{a.sort_by{|e|e.values_at *k}}

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


Title: Multiple-Key Sorting

Body:
Haskell, 38 bytes

import Data.List
sortOn.flip(map.(!!))

Usage example: ( sortOn.flip(map.(!!)) ) [2,1] [[9,2,-2,-10,-6], [3,-4,-2]] -> [[3,-4,-2],[9,2,-2,-10,-6]].

Non-pointfree: f k v=sortOn(\x->map(\y->x!!y)k)v.


问:
Print all integers
Write a program or function which will provably print all integers exactly once given infinite time and memory.

Possible outputs could be:

```<code>0, 1, -1, 2, -2, 3, -3, 4, -4, …

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -2, -3, -4, -5, -6, -7, -8, -9, 10, 11, …
</code>```

This is not a valid output, as this would never enumerate negative numbers:

<s>```0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, …```</s>

The output must be in decimal, unless your language does not support decimal integer (in that case use the natural representation of integers your language uses).

Your program has to work up to the numbers with the biggest magnitude of the standard integer type of your language.

Each integer must be separated from the next using any separator (a space, a comma, a linebreak, etc.) that is not a digit nor the negative sign of your language.

The separator must not change at any point.

The separator can consist of multiple characters, as long as none of them is a digit nor the negative sign (e.g. ,  is as valid as just ,).

Any supported integer must eventually be printed after a finite amount of time.

Scoring

This is code-golf, so the shortest answer in bytes wins

Leaderboard

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

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

答:
QBIC, 14 bytes

```<code>{?1-q ?q q=q+1
</code>```

qis 1 by default in QBIC, so this prints (1-1=) 0, 1, -1, 2, -2... separated by line breaks.

Title: Print all integers

Body:
QBIC, 14 bytes

{?1-q ?q q=q+1

qis 1 by default in QBIC, so this prints (1-1=) 0, 1, -1, 2, -2... separated by line breaks.


答:
Haskell, 50 bytes

```<code>x#y=show$max x$read y
f s|elem '.'s=1.4#s|1<2=18#s
</code>```

Usage example: f "1.0" -> "1.6".

Haskell's strict type requires usage of strings as input and output. Howevers, read, max and show are polymorphic and handle all numeric types.

Title: Yes, of course I'm an adult!

Body:
I think we've all done this as a kid: some websites require a minimum age of 18, so we just subtract a few years from the year of birth and voilà, we 'are' 18+.

In addition, for most rides at amusement parks the minimum height to enter is 1.40 meters (here in The Netherlands it as at least). Of course this can be cheated less easily than age, but you could wear shoes with thick heels, put your hair up, wear a hat, stand on your toes, etc.

Input:

Your program/function accepts a positive integer or decimal.

Output:

Is the input an integer >= 18? Simply print the input.

Is the input an integer 0-17? Print 18.

Is the input a decimal >= 1.4? Simply print the input.

Is the input a decimal 0.0-1.4? Print 1.4.

Challenge rules:

Assume the input will always be in the range of 0-122 (oldest woman ever was 122) or 0.0-2.72 (tallest man ever was 2.72).

You are allowed to take the input as a String, object, or anything else you prefer.

The decimal inputs will never have more than three decimal places after the decimal point.

2 or 2. both aren't valid outputs for 2.0. You are free to output 2.00 or 2.000 instead of 2.0 however.

Just like the input the output will never have more than three decimal places after the point.

General rules:

This is code-golf, so shortest answer in bytes wins.

Don't let code-golf languages discourage you from posting answers with non-codegolfing languages. Try to come up with an as short as possible answer for 'any' programming language.

Standard rules apply for your answer, so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters, full programs. Your call.

Default Loopholes are forbidden.

If possible, please add a link with a test for your code.

Also, please add an explanation if necessary.

Test cases:

```<code>0      ->  18
1      ->  18
2      ->  18
12     ->  18
18     ->  18
43     ->  43
115    ->  115
122    ->  122

0.0    ->  1.4
1.04   ->  1.4
1.225  ->  1.4
1.399  ->  1.4
1.4    ->  1.4
1.74   ->  1.74
2.0    ->  2.0
2.72   ->  2.72
</code>```

Body:
Haskell, 50 bytes

x#y=show$max x$read y
f s|elem '.'s=1.4#s|1<2=18#s

Usage example: f "1.0" -> "1.6".

Haskell's strict type requires usage of strings as input and output. Howevers, read, max and show are polymorphic and handle all numeric types.


答:
Powershell : 58 Bytes

Bit longer than i'd expected, so many brackets required to have it run correctly.

```<code>.({({1.4},$i)[$i-gt1.4]},{({18},$i)[$i-gt18]})[$i-is[int]]
</code>```

Input as $i

```<code>. #Execute the code.. required.
( #First block
    { #Value if-false of first block
        (
        {1.4} #Return Val
        , #Or
        $i #Return Input
        )[$i-gt1.4] #If input is greater than Val
    },{ #Next Block
    ({18},$i)[$i-gt18]} #Same with different val
)[$i-is[int]] #Decides based on if val is default int
</code>```

Test Cases:

```<code>@(0,1,2,12,18,43,115,122,0.0,1.04,1.225,1.399,1.4,1.74,2.0,2.72) | % {
$i = $_
Write-Host $i`t`t -NoNewline
.({({1.4},$i)[$i-gt1.4]},{({18},$i)[$i-gt18]})[$i-is[int]]
}
</code>```

returns :

```<code>0       18
1       18
2       18
12      18
18      18
43      43
115     115
122     122
0       1.4
1.04    1.4
1.225   1.4
1.399   1.4
1.4     1.4
1.74    1.74
2(.0)   2      (this is a value of type 'double' - the default formatting of powershell doesn't add decimals, but the returned value is of the correct type)
2.72    2.72
</code>```

Proof of 2 == 2.0

```<code>$i = 2.0
$q = .({({1.4},$i)[$i-gt1.4]},{({18},$i)[$i-gt18]})[$i-is[int]]
$q.GetType().Name
Double
</code>```

Title: Yes, of course I'm an adult!

Body:
Powershell : 58 Bytes

Bit longer than i'd expected, so many brackets required to have it run correctly.

.({({1.4},$i)[$i-gt1.4]},{({18},$i)[$i-gt18]})[$i-is[int]]

Input as $i

. #Execute the code.. required.
( #First block
    { #Value if-false of first block
        (
        {1.4} #Return Val
        , #Or
        $i #Return Input
        )[$i-gt1.4] #If input is greater than Val
    },{ #Next Block
    ({18},$i)[$i-gt18]} #Same with different val
)[$i-is[int]] #Decides based on if val is default int

Test Cases:

@(0,1,2,12,18,43,115,122,0.0,1.04,1.225,1.399,1.4,1.74,2.0,2.72) | % {
$i = $_
Write-Host $i`t`t -NoNewline
.({({1.4},$i)[$i-gt1.4]},{({18},$i)[$i-gt18]})[$i-is[int]]
}

returns :

0       18
1       18
2       18
12      18
18      18
43      43
115     115
122     122
0       1.4
1.04    1.4
1.225   1.4
1.399   1.4
1.4     1.4
1.74    1.74
2(.0)   2      (this is a value of type 'double' - the default formatting of powershell doesn't add decimals, but the returned value is of the correct type)
2.72    2.72

Proof of 2 == 2.0

$i = 2.0
$q = .({({1.4},$i)[$i-gt1.4]},{({18},$i)[$i-gt18]})[$i-is[int]]
$q.GetType().Name
Double


问:
Write a Chat Ping Counter
Your task is to write a program, that given a list of chat messages, count how many times each person gets pinged, so I can know how popular everyone is.  But, since I have to do it surreptitiously, I need it to be as small as possible so I can hide the code.

Specs

The input comes in a list of 2-tuples, with each item being of the form ("username", "message").

A ping to another user is defined as an @ followed by 3 or more letters that unambiguously refers to that user.

However, you also have to consider replies, which have to start with :messageid followed by a space.

Assume the first message has id 0 and proceed sequentially.

Output each user and say how many times each one got pinged.

The output can be in any order/reasonable format.

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

Test Cases

```<code>[["AlexA.", "I am wrong"], ["Quartatoes", "@Alex you are very wrong"], ["AlexA.", ":1 I am only slightly wrong"]]
AlexA.: 1
Quartatoes: 1

[["Doorknob", "I have never eaten an avocad."], ["AquaTart", ":0 I will ship you an avocad"], ["AlexA.", ":0 this is shocking"]]
Doorknob: 2
AquaTart: 0
AlexA.: 0

[["Geobits", "I like causing sadness through downvotes."], ["Flawr", "I want to put random message ids in my chat messages :0 askjdaskdj"]]
Geobits: 0
Flawr: 0

[["Downgoat", "goatigfs.com/goatgif"], ["Downotherthing", "@Downgoat cool gifs"], ["Dennis", "@Down cool gifs this is an ambiguous ping"]]
Downgoat: 1
Downotherthing: 0
Dennis: 0
</code>```

Title: Write a Chat Ping Counter

Body:
PHP, 227 Bytes

foreach($_GET[a]as $c){$r[]=&$n[$c[0]]??$n[$c[0]]=0;preg_match("#^(:(\d+)|@(\w+))#",$c[1],$m);$m[2]==""?!$m[3]?:count($a=preg_grep("#^{$m[3]}#",array_keys($n)))>1?:$n[end($a)]++:$r[$m[2]]++;}foreach(($n)as$k=>$v)echo"$k: $v\n";


答:
Julia, <s>26</s> 25 bytes

!n=1-sum(map(!,n÷(2:n)))
```
<p>Try it online!</p>
<h3>Background</h3>
<p>This uses the property</p>
<p><img src="https://i.stack.imgur.com/rhDhP.png" alt="property by David W. Wilson" /></p>
<p>from A002321, which leads to the following recursive formula.</p>
<p><img src="https://i.stack.imgur.com/VjAmY.png" alt="recursive formula" /></p>
<h3>How it works</h3>
<p>We redefine the unary operator <strong>!</strong> for our purposes.</p>
<p><code>n÷(2:n)</code> computes all required quotients, our redefined <strong>!</strong> is mapped over them, and finally the sum of all recursive calls is subtracted from <strong>1</strong>.</p>
<p>Unfortunately,</p>
<pre class="lang-julia prettyprint-override"><code>!n=1-sum(!,n÷(2:n))
</code>```

does not work since dyadic sum will choke on an empty collection.

!n=n<2||1-sum(!,n÷(2:n))
```

fixes this, but it doesn't save any bytes and returns True for input 1.

Title: Compute the Mertens function

Body:
Given a positive integer n, compute the value of the Mertens function \$M(n)\$ where:

$$M(n) = \Sigma_{k=1}^{n}\mu(k)$$

and \$\mu(k)\$ is the Möbius function where \$μ(k) = 1\$ if \$k\$ has an even number of distinct prime factors, \$-1\$ if \$k\$ has an odd number of distinct prime factors, and \$0\$ if the prime factors are not distinct.

This is code-golf so create the shortest code for a function or program that computes the Mertens function for an input integer n > 0.

This is the OEIS sequence A002321.

Test Cases

```<code>n M(n)
1 1
2 0
3 -1
4 -1
5 -2
6 -1
7 -2
8 -2
9 -2
10 -1
117 -5
5525 5
7044 -25
8888 4
10000 -23
</code>```

Body:
Julia, <s>26</s> 25 bytes

!n=1-sum(map(!,n÷(2:n)))

Try it online!

Background

This uses the property

from A002321, which leads to the following recursive formula.

How it works

We redefine the unary operator ! for our purposes.

n÷(2:n) computes all required quotients, our redefined ! is mapped over them, and finally the sum of all recursive calls is subtracted from 1.

Unfortunately,

!n=1-sum(!,n÷(2:n))

does not work since dyadic sum will choke on an empty collection.

!n=n<2||1-sum(!,n÷(2:n))

fixes this, but it doesn't save any bytes and returns True for input 1.