text:
Detect my accent
Your task is to write a program or function that detects accents in UTF-8 input. The catch is that your code must be written entirely in an 8-bit character encoding. The code will output a single integer which is the count of the number of accented letters in the input. Since Unicode is huge, the test input will consist solely of the characters found in Windows-1252, stored in the UTF-8 encoding, then treated as ASCII with extended characters (0x09, 0x0A, 0x0D, 0x20-0xFF only). The input won't contain any characters below 0x20, except for the three common ones, 0x09 (tab), 0x0A (line feed) & 0x0D (carriage return). It also won't contain 0x7F.
Unicode permits most common accented characters to be represented in multiple ways (only two for the characters in this challenge). é could be a pre-composed character: U+00E9 (C3 A9 in UTF-8) or a basic letter plus a combining mark: U+0065+U+0301 (65+CC 81 in UTF-8). Your code must correctly handle both.
In the following table * marks an accented letter. All letters that have two forms will be considered accented, plus Œ, œ, Æ & æ. All other characters will be considered as symbols or non-accented letters.
1252  Char  Unicode   Char  Unicode
         Bytes           Bytes
   Accented?
-----------------------------------------
80 _  €  3  U+20AC
81 Undefined
82 _  ‚  3  U+201A
83 _  ƒ  2  U+0192
84 _  „  3  U+201E
85 _  …  3  U+2026
86 _  †  3  U+2020
87 _  ‡  3  U+2021
88 _  ˆ  2  U+02C6
89 _  ‰  3  U+2030
8A *  Š  2  U+0160    Š  3  U+0053 U+030C
8B _  ‹  3  U+2039
8C *  Œ  2  U+0152
8D Undefined
8E *  Ž  2  U+017D    Ž  3  U+005A U+030C
8F Undefined
90 Undefined
91 _  ‘  3  U+2018
92 _  ’  3  U+2019
93 _  “  3  U+201C
94 _  ”  3  U+201D
95 _  •  3  U+2022
96 _  –  3  U+2013
97 _  —  3  U+2014
98 _  ˜  2  U+02DC
99 _  ™  3  U+2122
9A *  š  2  U+0161    š  3  U+0073 U+030C
9B _  ›  3  U+203A
9C *  œ  2  U+0153
9D Undefined
9E *  ž  2  U+017E    ž  3  U+007A U+030C
9F *  Ÿ  2  U+0178    Ÿ  3  U+0059 U+0308
A0 _     2  U+00A0
A1 _  ¡  2  U+00A1
A2 _  ¢  2  U+00A2
A3 _  £  2  U+00A3
A4 _  ¤  2  U+00A4
A5 _  ¥  2  U+00A5
A6 _  ¦  2  U+00A6
A7 _  §  2  U+00A7
A8 _  ¨  2  U+00A8
A9 _  ©  2  U+00A9
AA _  ª  2  U+00AA
AB _  «  2  U+00AB
AC _  ¬  2  U+00AC
AD _  2  U+00AD
AE _  ®  2  U+00AE
AF _  ¯  2  U+00AF
B0 _  °  2  U+00B0
B1 _  ±  2  U+00B1
B2 _  ²  2  U+00B2
B3 _  ³  2  U+00B3
B4 _  ´  2  U+00B4
B5 _  µ  2  U+00B5
B6 _  ¶  2  U+00B6
B7 _  ·  2  U+00B7
B8 _  ¸  2  U+00B8
B9 _  ¹  2  U+00B9
BA _  º  2  U+00BA
BB _  »  2  U+00BB
BC _  ¼  2  U+00BC
BD _  ½  2  U+00BD
BE _  ¾  2  U+00BE
BF _  ¿  2  U+00BF
C0 *  À  2  U+00C0    À  3  U+0041 U+0300
C1 *  Á  2  U+00C1    Á  3  U+0041 U+0301
C2 *  Â  2  U+00C2    Â  3  U+0041 U+0302
C3 *  Ã  2  U+00C3    Ã  3  U+0041 U+0303
C4 *  Ä  2  U+00C4    Ä  3  U+0041 U+0308
C5 *  Å  2  U+00C5    Å  3  U+0041 U+030A
C6 *  Æ  2  U+00C6
C7 *  Ç  2  U+00C7    Ç  3  U+0043 U+0327
C8 *  È  2  U+00C8    È  3  U+0045 U+0300
C9 *  É  2  U+00C9    É  3  U+0045 U+0301
CA *  Ê  2  U+00CA    Ê  3  U+0045 U+0302
CB *  Ë  2  U+00CB    Ë  3  U+0045 U+0308
CC *  Ì  2  U+00CC    Ì  3  U+0049 U+0300
CD *  Í  2  U+00CD    Í  3  U+0049 U+0301
CE *  Î  2  U+00CE    Î  3  U+0049 U+0302
CF *  Ï  2  U+00CF    Ï  3  U+0049 U+0308
D0 _  Ð  2  U+00D0
D1 *  Ñ  2  U+00D1    Ñ  3  U+004E U+0303
D2 *  Ò  2  U+00D2    Ò  3  U+004F U+0300
D3 *  Ó  2  U+00D3    Ó  3  U+004F U+0301
D4 *  Ô  2  U+00D4    Ô  3  U+004F U+0302
D5 *  Õ  2  U+00D5    Õ  3  U+004F U+0303
D6 *  Ö  2  U+00D6    Ö  3  U+004F U+0308
D7 _  ×  2  U+00D7
D8 _  Ø  2  U+00D8
D9 *  Ù  2  U+00D9    Ù  3  U+0055 U+0300
DA *  Ú  2  U+00DA    Ú  3  U+0055 U+0301
DB *  Û  2  U+00DB    Û  3  U+0055 U+0302
DC *  Ü  2  U+00DC    Ü  3  U+0055 U+0308
DD *  Ý  2  U+00DD    Ý  3  U+0059 U+0301
DE _  Þ  2  U+00DE
DF _  ß  2  U+00DF
E0 *  à  2  U+00E0    à  3  U+0061 U+0300
E1 *  á  2  U+00E1    á  3  U+0061 U+0301
E2 *  â  2  U+00E2    â  3  U+0061 U+0302
E3 *  ã  2  U+00E3    ã  3  U+0061 U+0303
E4 *  ä  2  U+00E4    ä  3  U+0061 U+0308
E5 *  å  2  U+00E5    å  3  U+0061 U+030A
E6 *  æ  2  U+00E6
E7 *  ç  2  U+00E7    ç  3  U+0063 U+0327
E8 *  è  2  U+00E8    è  3  U+0065 U+0300
E9 *  é  2  U+00E9    é  3  U+0065 U+0301
EA *  ê  2  U+00EA    ê  3  U+0065 U+0302
EB *  ë  2  U+00EB    ë  3  U+0065 U+0308
EC *  ì  2  U+00EC    ì  3  U+0069 U+0300
ED *  í  2  U+00ED    í  3  U+0069 U+0301
EE *  î  2  U+00EE    î  3  U+0069 U+0302
EF *  ï  2  U+00EF    ï  3  U+0069 U+0308
F0 _  ð  2  U+00F0
F1 *  ñ  2  U+00F1    ñ  3  U+006E U+0303
F2 *  ò  2  U+00F2    ò  3  U+006F U+0300
F3 *  ó  2  U+00F3    ó  3  U+006F U+0301
F4 *  ô  2  U+00F4    ô  3  U+006F U+0302
F5 *  õ  2  U+00F5    õ  3  U+006F U+0303
F6 *  ö  2  U+00F6    ö  3  U+006F U+0308
F7 _  ÷  2  U+00F7
F8 _  ø  2  U+00F8
F9 *  ù  2  U+00F9    ù  3  U+0075 U+0300
FA *  ú  2  U+00FA    ú  3  U+0075 U+0301
FB *  û  2  U+00FB    û  3  U+0075 U+0302
FC *  ü  2  U+00FC    ü  3  U+0075 U+0308
FD *  ý  2  U+00FD    ý  3  U+0079 U+0301
FE _  þ  2  U+00FE
FF *  ÿ  2  U+00FF    ÿ  3  U+0079 U+0308

Input will be in any 8-bit encoding which is a super-set of ASCII, i.e. the lower half of the code points will match exactly with ASCII, the upper half (0x80-0xFF) will be used exclusively for multi-byte UTF-8 encoded codepoints, e.g. “ (U+201C) will be treated as both three bytes and three characters by your code: E2 80 9C
Language features or pre-existing libraries that convert character encodings or handle Unicode are forbidden, e.g. JSON (can convert Unicode text to hex), Unicode flag on regex, etc.

Sample output and input:

3 Zoë reads the encyclopædia in a café
0 Zoe reads the encyclopaedia in a cafe
1 Zoë (pre-composed character, 3 codepoints, 4 bytes)
1 Zoë (base letter + combining mark, 4 codepoints, 5 bytes)
2 déjà vu

Scoring
Simple code-golf: lowest number of bytes wins!
This is a re-write as my computer crashed just before posting the first version and I lost all but the first few lines of the challenge. Apologies if I've left anything out!

At the start of the question you say that the input will be in UTF-8, but later on you say "any 8-bit encoding which is a super-set of ASCII". I don't think that the latter is well-specified. There are a potentially unlimited number of ASCII extensions. 2. What about ñ, ø, etc? I believe that technically neither of those is an accented character, at least in the languages which use them: rather they are full letters of the alphabet. 3. Could you please list the combining characters which we must take into account?

@PeterTaylor They are accented in English, i.e. they look like an English letter with an accent, therefore they will be considered as accented letters. The input will be transmitted as UTF-8, but mistakenly interpreted by the code as ASCII, since it doesn't know about encodings other than 8-bits.

Can the input contain accented characters followed by combining accents, such as é̀́̀́̀́̀́? How should they be counted?

@Pietu1998 Since that combination can't be converted back into Windows-1252 you can safely assume that you won't have to handle it.

Please provide a full list of all accented characters, using all permitted variations.

The remainder of the characters can be determined by their visual appearance.  I think this is too vague and should be spelled out more explicitly.  Is Ø an accented character?  Its tedious, but I you should tabulate this for each character of provide a list of codepoint (or equivalent) ranges

I count 5 # marks in your table - is that right?

What is the character between ¬ and ® - it renders as invisible for me on chrome, firefox and safari. (looks like some sort of hyphen/dash when pasted into emacs.  codepoint: 0xAD html: )

@DigitalTrauma Yes, there are 5 #s in the table. These characters are unassigned in Windows-1252. You are correct, the "invisible" character is , U+00AD.

@PeterTaylor It is unclear what is unclear. Would you please clarify what needs clarifying?

I cast that vote at the same time as I left my comment. But looking at the edited version, I don't understand what all the columns of the table represent (the first two are clear, but what are the rest?); and I still think you need to list the combining characters which must be taken into account.

@PeterTaylor Do you mean the codepoints of the combining marks?

Yes, exactly that.

Outside of this challenge, a lot of those characters are far from being accents, e.g. æ, œ, ß, ð, þ

@Fatalize I based whether a character should be considered an accented letter or not based on how likely it is to appear in English text and its appearance. A lot of people wouldn't know the sound values of ß (looks like B but isn't), ð (looks like d but isn't), þ (looks like p or b but isn't), etc. (which, although are included in Windows-1252, are not accented in this challenge) but most people would be able to recognise æ, œ as being almost the same as ae, oe. æon -> aeon -> (US) eon. I'm not saying that these characters are actually accented.

@PeterTaylor I've updated the table again to include the codepoints. Do you want me to write all the answers as well?

Mathematica, 46 bytes
Count[Characters@#,c_/;RemoveDiacritics@c!=c]&

Explanations:
Chatacters extract every characters in the string. Note that there is a difference between two Zoë even if they look the same:
Characters["Zoë"]
(* {"Z", "o", "ë"} *)

Characters["Zoë"]
(* {"Z", "o", "e", "̈ ̈"} *)

Here, the pattern c_/;RemoveDiacritics@c!=c will be matched with those characters that change with diacritics removed. For the first case, only ë will match since ë becomes e. While for the second case, only ̈ will match since it becomes nothing. Whatever case the string is, the counting will be correct.
Test cases:
f=%; (* assign the function to f. *)

f["Zoë reads the encyclopædia in a café"]
(* 3 *)
f["Zoe reads the encyclopaedia in a cafe"]
(* 0 *)
f["Zoë"]
(* 1 *)
f["Zoë"]
(* 1 *)
f["déjà vu"]
(* 2 *)

Unfortunately, this answer is invalid because it uses a built in library/feature of the language.

@CJDennis I don't really get it. The challange forbiddens libraries that convert character encodings or handle Unicode, however neither "Characters" nor "RemoveDiacritics" convert encodings.

How does the built-in function work if it isn't just handling Unicode? Your code certainly doesn't initially treat "ë" as two bytes/characters.

@CJDennis I'm adding some explanations.


text:
10 9 8 7 6 5 4 3 2 1... Print 2016
As a spin-off to my challenge over at Puzzling, your goal is to output 2016.
Rules:

You must include the numbers 10 9 8 7 6 5 4 3 2 1 in that order. They can be used as individual integers or concatenated together (like 1098), but the 10 may not be separated into 1 and 0 - no character(s) may be present between the digits. Note that, in some languages, 10 may not actually represent the integer literal 10, which is acceptable.
Your code must not contain any other numbers or pre-defined number variables or constants (so T in Pyth is not allowed, since it is a numeric constant).
You must calculate 2016 using numerics. Simply outputting 2016 without performing any operations on the required numbers (for example, by decoding an encoded string consisting of only alphabetic characters) is not allowed. Outputting 2016 in pieces (such as 20, then 16) is also not allowed; you must have a single output consisting of the numeric value 2016.
The valid answer with the fewest bytes wins.

@nicael I'm pretty sure solving the puzzle has been done. We've had several of these "insert operators to solve an equation" challenges, but they are exceptional hard to search for.

The previous revision (2) was more interesting actually. The new is just printing the string, the calculation was already made in your puzzling question...

Just a few questions based on what I can see on the current question: 1) Can we calculate 20 and 16 and print them one after the other or does the calculated number need to be 2016 before printing? 2) Are functions allowed? 3) Is concatenation of digits allowed? e.g. 1098 (I'm assuming yes by previous comments, but just to confirm) 4) Does "calculate 2016 using integers" mean that we can never have floats anywhere in an intermediate step? e.g. can I square root a number and round down?

What happens if I have a language where "10" is not treated as the number ten, but rather a one followed by a zero and there was no way around it? Is such a language disqualified? (example language: Befunge) 6) Can we use a predefined number variable in place of 10, e.g. T987654321?

@Sp3000 1 No. 2 No. 3 Yes. 4 Floats are OK as long as you don't break any other rules. 5 10 must be included so you would need to handle that somehow. 6 As long as 10 appears before T.

Thanks for clarifying. Just regarding 5 and 6, does "10" must be included mean the character 1 then the character 0, or something that represents the number ten? I think that's what I was confused about.

@Sp3000 1 then 0 immediately after. Imagine if I use Find on your code and search for 10. If it doesn't exist, it's not a valid entry.

k, that makes sense. Sorry for the question barrage!

Clarification about Pyth: T is a variable, not a constant.

I’m voting to close this question because it has unobservable requirements of "using arithmetic" and "not allowing numeric constants".

Jelly, 17 15 14 bytes
109876:54+3_21

Try it online!
How it works
109876:54+3_21

109876            Initialize the left argument as 109876.
      :54         Perform integer division by 54, yielding 2034.
         +3       Add 3, yielding 2037.
           _21    Subtract 21, yielding 2016.

Hexagony, 61 bytes
Not gonna win, but I just wanted to do a challenge in Hexagony.
This uses a different method than other answers (much worse). It takes some factors of 2016 (2,3,6,7,8) and multiplies them all together.
Minified:
\109.8/7}_=\"6<}{>...$_5_4/*!@...../}3.."2\/="*=}<*...$1>"*"/

Unminified:
    \ 1 0 9 .
   8 / 7 } _ =
  \ " 6 < } { >
 . . . $ _ 5 _ 4
/ * ! @ . . . . .
 / } 3 . . " 2 \
  / = " * = } <
   * . . . $ 1
    > " * " /

Explanation coming soon;

"Explanation coming soon;" I think we have a different understanding of 'soon'. ;P

@KevinCruijssen Whoops, I completely forgot about this. ... And now I don't understand how it works anymore. Great.

Pyth, 16 bytes
+/109876 54-3 21

Does integer division, then adds (3-21).
Try it here.

TI-BASIC, 17 15 bytes
int(109876/54-√(321

This uses @nicael's method.
17 bytes:
10+9*8-7+654*3-21

This solution from Puzzling can be directly translated into TI-BASIC.

Also valid in Japt, and probably some others.

Also works in PowerShell, and Mathematica (Wolfram), and I would imagine many, many others. And probably works in dozens more with trivial modifications.

A lovely polyglot solution

If you want to take the other languages, I'll delete my community wiki one.

Japt, 17 16 bytes
Â(109876/54-321q

I hate this 17. Probably will find another solution. YAYZ.
Explanation:

321q is a square root of 321.
~~ floors the number.

Try it online!

Â == ~~ :-)

109876/54-321¬f is 15 :-D

@Eth but f doesn't work, no?

It should be fixed. But the interpreter is down for maintenance right now, I'll get it back up momentarily.

109876/54-321q)f now works. The other suggestion doesn't.

@Eth your first suggestion does work and provide the same nice 16 bytes, not going to upgrade. (Also because it'll render my answer non-competing)

Yep, just letting you know that it works again.

Matlab / Octave, 23 bytes
(10-9+8-7)^(6-5+4)*3*21

Try it online

bc, 14
109876/54+3-21

Nothing exciting here - borrows from other answers.

The dc equivalent 109876 54/3+21-p scores 16, but doesn't warrant an answer of its own.

Haskell, 31 bytes
[10,9*8*7+const 6 5..]!!4+3*2*1

Not the shortest, 10+9*8-7+654*3-21 like seen in other answers works in Haskell too, but something different.
This builds a list starting with 10 and 9*8*7+6 = 510, so the offset is 500 for the following elements. The whole list is [10,510,1010,1510,2010,2510 ...]. We pick the 4th element (index 0-based), i.e. 2010 and add 3*2*1 = 6. Voilà.
I use const 6 5 = 6 to get rid of the 5 which is not needed.

Python 2, 20 bytes
print 109876/54+3-21

Again, that same boring 2016.(740). Makes use of the fact that if you don't have a decimal number in your expression it returns an integer.

Polyglot, 17 Bytes
10+9*8-7+654*3-21
This code, first used in Thomas Kwa's TI-BASIC answer, also works in:

AppleScript (full program)
bc (full program)
Math++ (expression or full program)
Mathematica (function, therefore not valid)
Powershell (full program)
Japt (full program)
JavaScript (console input, therefore not valid) Needs second verification
Perl 5 (function, therefore not valid). Needs second verification
Haskell (function, therefore not valid)
Python REPL (expression, so REPL environment is needed to get the output)

And, what's the point?

@nicael I'm ---going--- am planning (unless Thomas Kwa wishes to add the other answers to his as well) to add all of the answers that involve this answer (except TI-BASIC) that I can find. Marked as Community so that others can contribute.

This is not a valid answer as it does not constitute a full program or function (AFAIK) in any of the specified languages.

@AlexA. It works fine here (Japt) as a full program.

@ThomasKwa So it's valid in 1 out of 6 of the listed languages.

@AlexA. This is a full program in AppleScript. Running this through AppleScript's Script Editor or through osascript outputs the value.

Why does this have downvotes?

Why the "function, therefore not valid" remarks? Functions are allowed by default.

I don't know about the other languages, but 10+9*8-7+654*3-21 is neither a JavaScript nor a Perl function.

@nimi The question says "print", which implies a program.

The Python REPL doesn't count as its own language

@AlexA. See relevant meta discussion

@FlagAsSpam: I don't see that "print" implies "program". Do we have the distinction between "print" and "output"? I can't remember, but may I err here. Default output methods for functions are their return value. Besides that, we have a meta topic that allows answers that work in repl environments, so if the repl prints for you, you're fine.

@nimi Just clarified with the OP: functions are now explicitly disallowed (see main post comments)

@Sp3000: Oh these invalidating rule changes ...

Math++, 17 bytes
_(109876/54)+3-21

Actually, this prints 2016.0. But there's really no way to print the exact string 2016 in this language.
The 17-byte TI-BASIC solution would also work here.

BotEngine, 42 39 36 13x2=26
v109876543210
>ee   e@  eRP

><> (fish), 18 bytes
10987**r65r4*n;321

explaination:
multiplies 9 8 and 7 together to get 504, reverses the stack and reverses it again right before the 4 is added, then multiplies 504 and 4 to get 2016. Then prints the number and ends the program before the last 3 numbers (i could do it after too with no difference, if that matters rules-wise).

 2, 15 chars / 17 bytes
109876/54+3-21⍜

Try it here (Firefox only).
Translates to round(109876/54+3-21).
Thanks to @Dennis for saving 2 bytes!

Java 7, 31 bytes
int c(){return 109876/54+3-21;}

Boring port from other answers, of which I believe @Dennis' Jelly answer was the first.

PHP, 27 bytes
<?=~~(109876/54+3-21);

(22 bytes) was too boring,
so I used 10 to 9 as separate numbers:
<?=10*(9-8+7-6),5+4-3+2<<1;

other solutions, mostly with small cheats:
30: <?=10**(9+8-7-6)/5+4*3+(2<<1);
30: <?=10*trim(9*8,7),6+5+4+3-2*1;
29: <?=10*trim(9*8,76),5*4-3-2+1;
31: <?=10*trim(9*8,765),4+(3*2<<1);
31: <?=10*trim(9*8,765),4*3+(2<<1);
32: <?=ceil(1098*76/54)+321+ord(~j);
33: <?=(10<<9)/876*543/M_PI*2-M_E&~1;

CJam, 15 bytes
109876 54/3+21-

Another port from Dennis' answer that I suspect works for many stack-based languages except 05AB1E, which seems to be the only stack-based answer besides Forth, which needs several more bytes.

Milky Way 1.6.5, 28 25 bytes
10+9*(8)7;^*6*5/4*3/2*A!1

Explanation
10+9*                      ` perform 10*9 (leaves 90 at TOS)
     (8)7;^*               ` get rid of 8 and multiply the TOS by 7
            6*5/4*3/2*A    ` perform TOS*6/5*4/3*2 (leaves 2016 at TOS)
                       !   ` output the TOS
                        1  ` push 1 to the stack

05AB1E, 15 bytes
109876 54÷3+21-

Try it online!
Port of Dennis' answer.

Forth, 22 bytes
Same calculation seen in other answers.
109876 54 / 3 + 21 - .

Try it online

C 37 bytes
main(){printf("%d",109876/54+3-21);}

Same theme as many present.

VBA, 15 bytes
?109876\54+3-21

(calculation unashamedly stolen from Dennis)

JavaScript (ES6), 21 bytes

f=

_=>~~(109876/54+3-21)

console.log(f())

If the "countdown" went to 0, it could be done in 19 bytes.

f=
_=>109876/54+3-21|0
console.log(f())

And, seeing as it's 2017 now, that can also be done in 21 bytes:

f=
_=>-~(109876/54+3-21)
console.log(f());

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/

sort: votes


text:
Lego Gear Train
Inspired by the Lego gear ratios challenge by Keith Randall.
I, too, plan on building a giant lego robot that will eventually be able to destroy the other robots in the never-before-mentioned competition.* In the process of constructing the robot, I will be using a lot of gear trains to connect different parts of the robot. I want you to write me the shortest program that will help me construct the complex gear trains that are required for such a complex task. I will, of course, only be using gears with radii 1, 2, 3, and 5 arbitrary-lego-units.
Each gear in the gear train has a specific integer coordinate on a 2D grid. The first gear is located at (0,0) and the final gear will be located at non-negative coordinates. The location and size of the first and last gears will be provided as input, your program must tell what gears go where to fill in the gaps.
Additionally, your program must use the minimum possible number of gears in the gear train. Fewer gears / train = more trains** = bigger and better robot of destruction.
Input will consist of one line:
X,Y,B,A

X and Y are the coordinates of the final gear. The first gear is always located at (0,0).  B and A are the radii of the final and initial gears, respectively. To add some difficulty, you need to make sure that the output gear rotates in the correct direction. If A and B have the same sign, then the output gear needs to rotate in the same direction, and an odd number of gears must be used. If they have opposite signs, then an even number of gears need to be used.
Output should be a list of the X location, Y location, and radii of each additional gear, one gear per line. If there are multiple minimal-gear solutions, print only one of your choice.  The order of gears in the output does not matter.
Examples (more equivalent solutions may be possible):
in
4,0,1,1
out
2,0,1

in
7,7,-2,-2
out
4,3,3
OR
0,7,5
OR
the above reflected over y=x line

in
7,8,-1,2
out
7,0,5
7,6,1
OR
7,0,5
1,8,5

in
7,7,2,-2
out
4,-3,3
7,1,2
12,1,3
12,7,3
OR
any permutation of the above, or reflected over y=x line
Now you're thinking with gear trains!

Here's the solutions to the above examples, visualized:

As far as I know, no problem is impossible unless the two input gears overlap or directly connect. You won't have to deal with this.
This is code golf, shortest answer wins.

*A future KOTH, anyone?
**CHOO CHOO!!

I would have it so that both the initial and final radii can be negative.

Welcome to Phi's Lego Gear Train Challenge. After 4 years in the Sandbox, hopefully it will have been worth the weight.

@wizzwizz4 Made the change.

Was this really in the sandbox for 4 years?

@RikerW More like 3 1/3.

C#, 660 bytes
using System.Linq;using System;class P{int p=1,x,y,r;P l;static void Main(){var Q="$&.$'7$(@$*R$'/$(8$)A'(A('A$+S$(0$)9'(9('9$*B$,T$*2$+;$,D$.V*,V,*V";var I=Console.ReadLine().Split(',').Select(int.Parse).ToList();int i=0,t,s=7,u,v,w,p=I[3]*I[2];for(var D=new[]{new P{r=Math.Abs(I[3]),l=new P{r=Math.Abs(I[2]),x=I[0],y=I[1],p=3}}}.ToList();i>=0;){P c=D[i++],l=c.l;for(;(l=l?.l)!=null&&(s=(t=c.x-l.x)*t+(t=c.y-l.y)*t-(t=c.r+l.r)*t)>0;);if(s==0&&l.p>2&p*c.p<0)for(i=-1;c.l.p<3;c=c.l)Console.WriteLine(c.x+","+c.y+","+c.r);for(t=0;s>0&t<66;t++)for(u=Q[t++]-36,v=Q[t++]-36,s=1;s++<5&Q[t]%9==c.r;w=u,u=v,v=-w,D.Add(new P{l=c,r=Q[t]/9-4,x=c.x+u,y=c.y+v,p=-c.p}));}}}

Try It Online
This was a lot of fun!! Complete program, accepts input from STDIN, output to STDOUT. Output is the gears in order from the end to the start. Usage:
Performs a simple Breadth First Search, which solves a 4-gear problem in less than a second. Branching factor isn't actually that large, so it's it should be good for considerably more (not really tested it). Sadly it uses Linq.
The Q string is a table of all allowed gear connections (i.e an r=3 and connect to an r=1 if dx=4 and dy=0) in one quadrant, which is then rotated to find the others. Every set of 3 bytes is the dx, dy, and radius information for a legal connection. The choice of ( as an offset was very deliberate: it was fun for once to be choosing an ASCII character for nice properties, rather than desperately trying to find nice properties for imposed ASCII characters.
I can probably do a better job of reading the input, but I've had no luck yet, not least because the Linq is paid for by the need for a list. I'm also very disappointed by the rotate code, I feel like that could be done in considerably fewer bytes.
Formatted and Commented Code with Q generator:
using System.Linq; // seems to pay today
using System;

class P
{
    static void GenQ()
    {
        int t, k = 0, m = 0;
        Func<P, P, int> C = (P c, P l) => (t = c.x - l.x) * t + (t = c.y - l.y) * t - (t = c.r + l.r) * t; // ==0 -> touching, <0 -> not touching, >0 -> overlap

        string str = "";

        string T(int i) => "" + (char)('$' + i); // $ is zero, '$' == 36, so we can mod and div by 9, and greater than " so we don't have to escape it

        foreach (int r in new[] { 1, 2, 3, 5 }) // at 0,0 (current gear)
            foreach (int s in new[] { 1, 2, 3, 5 }) // gear to place
                for (int i = 0; i <= r + s; i++) // x
                    for (int j = 1; j <= r + s; j++, m++) // y
                        if (C(new P { r = r }, new P { r = s, x = i, y = j }) == 0) //
                        {
                            str += T(i) + T(j) + T(r + s * 9);
                            k++;
                        }

        System.Console.WriteLine("K : " + k);
        System.Console.WriteLine("M : " + m);
        System.Console.WriteLine(str);
        System.Console.ReadKey(true);
        return;
    }

    int p=1, // parity
        x, // x
        y, // y
        r; // radias (TODO: store radias^2 ?)
    P l; // previous in search list

    static void Main()
    {
        //GenQ();

        // '$' == 36 (4*9)
        // 3char blocks: x,y,r+9*s
        var Q="$&.$'7$(@$*R$'/$(8$)A'(A('A$+S$(0$)9'(9('9$*B$,T$*2$+;$,D$.V*,V,*V"; // quarter table

        // primative read ints
        var I=Console.ReadLine().Split(',').Select(int.Parse).ToList();

        int i=0, // position in Due
            t, // check differential cache, position in Q
            s=7, // check cache, rotation counter (>0)
            u, // rotation x
            v, // rotation y
            w, // rotation x cache
            p=I[3]*I[2]; // parity (>0 -> same, even ; <0 -> different, odd)

        // due (not point using a queue, the search space grows exponentially)
        for(var D=new[]{
                new P{r=Math.Abs(I[3]), // start (p==1)
                    l=new P{r=Math.Abs(I[2]),x=I[0],y=I[1],p=3} // terminal (detect with p==3)
                }}.ToList();
            i>=0;) // infinite number of configurations, no bounds, i is escape term
        {
            P c=D[i++], // current
                l=c.l; // check, initially the one before the previous (we know we are touching last already)

            // 'checks' c against l
            //Func<int>C=()=>(t=c.x-l.x)*t+(t=c.y-l.y)*t-(t=c.r+l.r)*t; // ==0 -> touching, >0 -> not touching, <0 -> overlap

            // check we arn't touching any before us (last thing we check is terminal)
            for(;(l=l?.l)!=null&& // for each before us (skipping the first one)
                (s=(t=c.x-l.x)*t+(t=c.y-l.y)*t-(t=c.r+l.r)*t)>0;); // check c against l and cache in s, ==0 -> touching, >0 -> not touching, <0 -> overlap

            if(s==0&& // touching last checked?
                l.p>2& // stopped on terminal?
                p*c.p<0) // correct parity? -> win
                for(i=-1; // escape
                    c.l.p<3;c=c.l) // for each that wasn't the first
                    Console.WriteLine(c.x+","+c.y+","+c.r);

            // enumerate possible additions, and queue them in due
            for(t=0;
                s>0& // not touching or overlapping anything (including terminal)
                t<66;t++) // 66 = Q.Length
                for(
                    u=Q[t++]-36, // '$'
                    v=Q[t++]-36,
                    s=1;s++<5& // rotate 4 times
                    Q[t]%9==c.r; // our raidus matches
                        w=u, // chache y value
                        u=v, // rotate
                        v=-w,
                        D.Add(new P // add
                        {
                            l=c,
                            r=Q[t]/9-4, // radius
                            x=c.x+u,
                            y=c.y+v,
                            p=-c.p // flip parity
                        }));
        }
    }
}

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/


text:
Tic-tac-toe with only crosses
Introduction
Everyone knows the game tic-tac-toe, but in this challenge, we are going to introduce a little twist. We are only going to use crosses. The first person who places three crosses in a row loses. An interesting fact is that the maximum amount of crosses before someone loses, is equal to 6:
X X -
X - X
- X X

That means that for a 3 x 3 board, the maximum amount is 6. So for N = 3, we need to output 6.
Another example, for N = 4, or a 4 x 4 board:
X X - X
X X - X
- - - -
X X - X

This is an optimal solution, you can see that the maximum amount of crosses is equal to 9. An optimal solution for a 12 x 12 board is:
X - X - X - X X - X X -
X X - X X - - - X X - X
- X - X - X X - - - X X
X - - - X X - X X - X -
- X X - - - X - - - - X
X X - X X - X - X X - -
- - X X - X - X X - X X
X - - - - X - - - X X -
- X - X X - X X - - - X
X X - - - X X - X - X -
X - X X - - - X X - X X
- X X - X X - X - X - X

This results in 74.
The task
The task is simple, given an integer greater than 0, output the maximum amount of crosses that can be placed with no three X's adjacent in a line along a row, column or diagonally.
Test cases
N     Output
1     1
2     4
3     6
4     9
5     16
6     20
7     26
8     36
9     42

More information can be found at https://oeis.org/A181018.
Rules

This is code-golf, so the submission with the least amount of bytes wins!
You may provide a function or a program.

So the question just boils down to using the formulas in the page you linked...

Related post over on Math.

@nicael As far as I can see, the OEIS article only contains lower bounds.

@PeterTaylor I do know that 100 is correct for 14. I don't know the result for 13 though.

The challenge would be a lot more interesting in my opinion if it could be a rectangular board with an input for height and width, but it's probably too late for that.

@PeterTaylor Well, after some research, it can be seen that if the size of the board can be expressed in the form 3k-1, the maximum amount of crosses would be ((N+1)/3)^2 * 4, with N being the size of the board. This can also be seen at N = 2, 5, 8, 11. These can be seen in the sequence: 1, 4, 6, 9, 16, 20, 26, 36, 42, 52, 64, 74, which are 2^2, 4^2, 6^2, 8^2, and so on.

The reason behind this is that the grid can be perfectly filled in with 2 x 2 squares of crosses, or a zigzag pattern, which fills half the board with crosses. Here is my solution for N = 14 (but not entirely proven).

Do you realise that your previous two comments contradict each other, because the zigzag pattern gives a counterexample to the 4/9(N+1)^2 at N=17?

@PeterTaylor I can't remember why I included the zigzag example, but it is wrong. That gives 98 for N=14. The reason behind is that the grid can be filled in with 2 x 2 squares, not the zigzag pattern.

I'm not sure how effective it may be, but an optimal game on a 3x3 board is played by playing a night's move away from your opponent's move

@CᴏɴᴏʀO'Bʀɪᴇɴ Yes, that also seems to be the case at the 12 x 12 board. With a knight starting at the top-left corner and ending at the bottom-right.

@Adnan Interesting... I wonder if there is any pattern in the boards that satisfy this problem?

Has anyone proven a result for input 15?

@KSFT Not that I know of

Would be cool to see this as a fastest code challenge.

Do we need to be able to prove answers correct?

And yes, you need to be able to prove your answer correct.

@PeterTaylor would the only way to prove that an answer is correct is to wait till the bruteforce programs finish?

@JuanPotato, exactly the opposite. No brute force program is ever going to prove that any other program is correct (although one might prove another answer incorrect). The only way to prove that an answer is correct is by demonstrating that it takes into account every configuration which can't be proven suboptimal.

@Luke Yeah, I realised that a while after I've posted the challenge, but the problem is that if there exists a formula for this, it would make no sense anymore.

Not a codegolf solution, but I have been playing with a "visual" solver the past few days.  You can access the jsfiddle here: http://jsfiddle.net/V92Gn/3899/ It attempts to find solutions via random mutations.  It won't stop if it finds the "correct" answer, but it can get to many of the correct solutions much quicker than those answers below.

@styletron That actually looks pretty amazing. This will probably simplify pattern recognition for certain grids. Thanks :)

Is an answer considered valid only if it passes all test cases up to 9 in a reasonable time?

@Sleafar It is considered valid if your program calculates the correct value for any N in 'unlimited' time. So theoretically, it should solve all N.

@Adnan disagree. And unlimited memory too?. My answer use a memory area of 999+999+99 integers. I can use some more chars and have 100000+100000+1000 integers, but what for? It will never use all this memory during our lifetime

@edc65 Yes, that is what I meant with theoretically solving the problem. Although in practice, we probably won't even reach the answer, if you have unlimited memory and unlimited time, it should be able to calculate the answer.

Thanks for the props on the fiddle I posted yesterday.  Using that code for N=20, I can prove that that ((N+1)/3)^2 * 4 formula is broken for at least N=20 which should have a max of 196 if that formula were correct.  I have at least 201 on a 20x20 grid here (png image).  I noticed a pattern trying to emerge of z tetriminos, so I manually tried that out and was able to fit 200 (png image) in the 20x20 grid.

Following up with my previous comment, removing 3 rows and columns from the manual job above yields 145 count for N=17 which also invalidates the formula since N=17 should have maxed out at 144.

@styletron It seems that the z-pattern is more efficient than the 2 x 2 square. I did not expect this, but this is very interesting!

@styletron, the alternating pattern in the OEIS comments also gives 145 for N=17.

@PeterTaylor Doh! You're right. Using that pattern also yields 200 for N=20.

Still waiting for the second review of my suggested changes to OEIS A181018, but the next few terms are a(13) = 86, a(14) = 100, a(15) = 114, a(16) = 130. I speculate that a(17) =? 146, but unless I find a major optimisation the calculation would take a month.

Pyth, 57 51 49 bytes
L.T.e+*]Ykbbsef!s.AMs.:R3ssmyBdsm_BdCBcTQsD^U2^Q2

Like @PeterTaylor's CJam solution, this is brute-force, so it runs in O(n22n2) time. The online interpreter doesn't finish within a minute for n=4.
Try it here for N<4.
Try the diagonals function.
L.T.e+*]Ykbb         y(b): diagonals of b (with some trailing [])
s e                  sum of the last (with most ones) array such that
f                    filter lambda T:
 ! s .AM                none of the 3 element sublists are all ones
   s .:R3               all 3 element sublists
   s s                  flatten
   myBd                 add the diagonals
   sm_B d               add the vertically flipped array and transpose
   CBcTQ                array shaped into Q by Q square, and its transpose
 sD ^U2 ^Q2             all binary arrays of length Q^2 sorted by sum

CJam (58 56 bytes)
2q~:Xm*{7Yb#W=}:F,Xm*{ee{~0a@*\+}%zS*F},_Wf%:z&Mf*1fb:e>

This is incredibly slow and uses a lot of memory, but that's code-golf for you.
Dissection
2q~:Xm*        e# Read input into X and find Cartesian product {0,1}^X
{7Yb#W=}:F,    e# Filter with a predicate F which rejects arrays with a 111
Xm*            e# Take the Cartesian product possible_rows^X to get possible grids
{              e# Filter out grids with an anti-diagonal 111 by...
  ee{~0a@*\+}% e#   prepending [0]*i to the ith row
  zS*F         e#   transposing, joining on a non-1, and applying F
},
_Wf%:z         e# Copy the filtered arrays and map a 90 degree rotation
&              e# Intersect. The rotation maps horizontal to vertical and
               e# anti-diagonal to diagonal, so this gets down to valid grids
Mf*            e# Flatten each grid
1fb            e# Count its 1s
:e>            e# Select the maximum

The number of valid rows is a tribonacci number and is \$\Theta(a^X)\$ where \$a\$ is the tribonacci constant, \$1.83928675\ldots\$. The number of grids generated in the Cartesian product is \$\Theta(a^{X^2})\$; the second filter will reduce the number somewhat, but the intersection is still probably \$\Theta(a^{X^4})\$.

An "efficient" approach ("merely" \$O(X a^{3X})\$) uses dynamic programming. Ungolfed in Java:
public class A181018 {
    public static void main(String[] args) {
        for (int i = 1; i < 14; i++) {
            System.out.format("%d:\t%d\n", i, calc(i));
        }
    }

    private static int calc(int n) {
        if (n < 0) throw new IllegalArgumentException("n");
        if (n < 3) return n * n;

        // Dynamic programming approach: given two rows, we can enumerate the possible third row.
        // sc[i + rows.length * j] is the greatest score achievable with a board ending in rows[i], rows[j].
        int[] rows = buildRows(n);
        byte[] sc = new byte[rows.length * rows.length];
        for (int j = 0, k = 0; j < rows.length; j++) {
            int qsc = Integer.bitCount(rows[j]);
            for (int i = 0; i < rows.length; i++) sc[k++] = (byte)(qsc + Integer.bitCount(rows[i]));
        }

        int max = 0;
        for (int h = 2; h < n; h++) {
            byte[] nsc = new byte[rows.length * rows.length];
            for (int i = 0; i < rows.length; i++) {
                int p = rows[i];
                for (int j = 0; j < rows.length; j++) {
                    int q = rows[j];
                    // The rows which follow p,q cannot intersect with a certain mask.
                    int mask = (p & q) | ((p << 2) & (q << 1)) | ((p >> 2) & (q >> 1));
                    for (int k = 0; k < rows.length; k++) {
                        int r = rows[k];
                        if ((r & mask) != 0) continue;

                        int pqrsc = (sc[i + rows.length * j] & 0xff) + Integer.bitCount(r);
                        int off = j + rows.length * k;
                        if (pqrsc > nsc[off]) nsc[off] = (byte)pqrsc;
                        if (pqrsc > max) max = pqrsc;
                    }
                }
            }

            sc = nsc;
        }

        return max;
    }

    private static int[] buildRows(int n) {
        // Array length is a tribonacci number.
        int c = 1;
        for (int a = 0, b = 1, i = 0; i < n; i++) c = a + (a = b) + (b = c);

        int[] rows = new int[c];
        int i = 0, j = 1, val;
        while ((val = rows[i]) < (1 << (n - 1))) {
            if (val > 0) rows[j++] = val * 2;
            if ((val & 3) != 3) rows[j++] = val * 2 + 1;
            i++;
        }

        return rows;
    }
}

What does the efficient approach run in?

@ThomasKwa, oh, it's still exponential, but I think it's justified to call it efficient because it's allowed me to extend the OEIS sequence by 3 terms.

@ThomasKwa, to be precise, it's O(n a^n) where a ~= 5.518.

C, 460 456 410 407 362 351 318 bytes
This is a really bad answer. It's an incredibly slow brute force approach. I'm trying to golf it a bit more by combining the for loops.
#define r return
#define d(x,y)b[x]*b[x+y]*b[x+2*(y)]
n,*b;s(i){for(;i<n*(n-2);++i)if(d(i%(n-2)+i/(n-2)*n,1)+d(i,n)+(i%n<n-2&&d(i,n+1)+d(i+2,n-1)))r 1;r 0;}t(x,c,l,f){if(s(0))r 0;b[x]++;if(x==n*n-1)r c+!s(0);l=t(x+1,c+1);b[x]--;f=t(x+1,c);r l>f?l:f;}main(c,v)char**v;{n=atol(v[1]);b=calloc(n*n,4);printf("%d",t(0,0));}

Test Cases
$ ./a.out 1
1$ ./a.out 2
4$ ./a.out 3
6$ ./a.out 4
9$ ./a.out 5
16$

Ungolfed
n,*b; /* board size, board */

s(i) /* Is the board solved? */
{
    for(;i<n*(n-2);++i) /* Iterate through the board */
            if(b[i%(n-2)+i/(n-2)*n]&&b[i%(n-2)+i/(n-2)*n+1]&&b[i%(n-2)+i/(n-2)*n+2] /* Check for horizontal tic-tac-toe */
                    || b[i] && b[i+n] && b[i+2*n] /* Check for vertical tic-tac-toe */
                    || (i%n<n-2
                            && (b[i] &&b [i+n+1] && b[i+2*n+2] /* Check for diagonal tic-tac-toe */
                                    || b[i+2*n] && b[i+n+1] && b[i+2]))) /* Check for reverse diagonal tic-tac-toe */
                    return 1;
    return 0;
}

t(x,c,l,f) /* Try a move at the given index */
{
    if(s(0)) /* If board is solved, this is not a viable path */
            return 0;
    b[x]++;
    if(x==n*n-1) /* If we've reached the last square, return the count */
            return c+!s(0);

    /* Try it with the cross */
    l=t(x+1,c+1);

    /* And try it without */
    b[x]--;
    f=t(x+1,c);

    /* Return the better result of the two */
    return l>f?l:f;
}

main(c,v)
char**v;
{
    n=atol(v[1]); /* Get the board size */
    b=calloc(n*n,4); /* Allocate a board */
    printf("%d",t(0,0)); /* Print the result */
}

Edit: Declare int variables as unused parameters; remove y coordinate, just use index; move variable to parameter list rather than global, fix unnecessary parameters passed to s(); combine for loops, remove unnecessary parentheses; replace && with *, || with +; macro-ify the 3-in-a-row check

How slow is it?

@Loovjo tried on my PC with some small changes to make it faster, 15ms for n=5, 12 sec for n=6 (input +1, time * 800)!

@edc65 That was my experience. Anything greater than 5 the performance was dramatically slower. I didn't bother with trying inputs greater than 6.

I started with 7 when I posted my comment. We'll see

You can squeeze out a few more chars with #define d(x,y)b[x]*b[x+y]*b[x+y+y]; by changing the start of s to s(i,m){for(m=n-2; and replacing all instances of n-2; and by changing b[x]++ to b[x++]++ and then replacing x==n*n-1 with x==n*n, x+1 with x, and x with x-1.

C 263 264 283 309
Edit A few bytes saved thx @Peter Taylor - less than I hoped. Then 2 bytes used to allocate some more memory, now I can try larger size, but it's becoming very time consuming.
Note While adding the explanation, I found out that i'm wasting bytes keeping the grid in the R array - so that you can to see the solution found ... it's not requested for this challenge!!
I removed it in the golfed version
A golfed C program that can actually find the answer for n=1..10 in reasonable time.
s,k,n,V[9999],B[9999],i,b;K(l,w,u,t,i){for(t=u&t|u*2&t*4|u/2&t/4,--l; i--;)V[i]&t||(b=B[i]+w,l?b+(n+2)/3*2*l>s&&K(l,b,V[i],u,k):b>s?s=b:0);}main(v){for(scanf("%d",&n);(v=V[i]*2)<1<<n;v%8<6?B[V[k]=v+1,k++]=b+1:0)V[k]=v,b=B[k++]=B[i++];K(n,0,0,0,k);printf("%d",s);}

My test:

7 -> 26 in 10 sec
8 -> 36 in 18 sec
9 -> 42 in 1162 sec

Less golfed and trying to explain
#include <stdio.h>

int n, // the grid size
    s, // the result
    k, // the number of valid rows
    V[9999], // the list of valid rows (0..to k-1) as bitmasks
    B[9999], // the list of 'weight' for each valid rows (number of set bits)
    R[99],  // the grid as an array of indices pointing to bitmask in V
    b,i; // int globals set to 0, to avoid int declaration inside functions

// recursive function to fill the grid
int K(
  int l, // number of rows filled so far == index of row to add
  int w, // number of crosses so far
  int u, // bit mask of the preceding line (V[r[l-1]])
  int t, // bit mask of the preceding preceding line (V[r[l-2]])
  int i) // the loop variables, init to k at each call, will go down to 0
{
  // build a bit mask to check the next line
  // with the limit of 3 crosses we need to check the 2 preceding rows
  t = u&t | u*2 & t*4 | u/2 & t/4;
  for (; i--; )// loop on the k possibile values in V
  {
    R[l] = i; // store current row in R
    b = B[i] + w; // new number of crosses if this row is accepted
    if ((V[i] & t) == 0) // check if there are not 3 adjacent crosses
      // then check if the score that we can reach from this point
      // adding the missing rows can eventually be greater
      // than the current max score stored in s
      if (b + (n + 2) / 3 * 2 * (n - l - 1) > s)
        if (l > n-2) // if at last row
          s = b > s ? b : s; // update the max score
        else  // not the last row
          K(l + 1, b, V[i], u, k); // recursive call, try to add another row
  }
}

int main(int j)
{
  scanf("%d", &n);

  // find all valid rows - not having more than 2 adjacent crosses
  // put valid rows in array V
  // for each valid row found, store the cross number in array B
  // the number of valid rows will be in k
  for (; i<1 << n; V[k] = i++, k += !b) // i is global and start at 0
    for (b = B[k] = 0, j = i; j; j /= 2)
      b = ~(j | -8) ? b : 1, B[k] += j & 1;
  K(0,0,0,0,k); // call recursive function to find the max score
  printf("%d\n", s);
}

This is essentially the same as my Java program but depth-first rather than breadth-first. I think you should be able to save at least a dozen characters by porting my buildRows method; maybe as many as 20 if for(scanf("%d",&n);(v=2*V[i++])<1<<n;v%8<6&&V[++j]=v+1)v&&V[++j]=v; is valid. (I don't have access to a C compiler right now).

@PeterTaylor i'll give it a look ... just the word tribonacci is scaring me

Your hard-coded 999 means that you would want to ignore that part. Although maybe you should really make it not hard-coded, so that in principle you can tackle larger inputs than 11 or 12.

@PeterTaylor it would work great if I had a .bitCount method in C to count bits. But in that initial fase I'compuitng the bit count in B, not only the bit masks in V

Ruby, 263 bytes
This is also a brute force solution and faces the same problems as the C answer by Cole Cameron, but is even slower since this is ruby and not C. But hey, it's shorter.
c=->(b){b.transpose.all?{|a|/111/!~a*''}}
m=->(b,j=0){b[j/N][j%N]=1
x,*o=b.map.with_index,0
c[b]&&c[b.transpose]&&c[x.map{|a,i|o*(N-i)+a+o*i}]&&c[x.map{|a,i|o*i+a+o*(N-i)}]?(((j+1)...N*N).map{|i|m[b.map(&:dup),i]}.max||0)+1:0}
N=$*[0].to_i
p m[N.times.map{[0]*N}]

Test cases
$ ruby A181018.rb 1
1
$ ruby A181018.rb 2
4
$ ruby A181018.rb 3
6
$ ruby A181018.rb 4
9
$ ruby A181018.rb 5
16

Ungolfed
def check_columns(board)
  board.transpose.all? do |column|
    !column.join('').match(/111/)
  end
end

def check_if_unsolved(board)
  check_columns(board) && # check columns
    check_columns(board.transpose) && # check rows
    check_columns(board.map.with_index.map { |row, i| [0] * (N - i) + row + [0] * i }) && # check decending diagonals
    check_columns(board.map.with_index.map { |row, i| [0] * i + row + [0] * (N - i) }) # check ascending diagonals
end

def maximum_crosses_to_place(board, index=0)
  board[index / N][index % N] = 1 # set cross at index
  if check_if_unsolved(board)
    crosses = ((index + 1)...(N*N)).map do |i|
      maximum_crosses_to_place(board.map(&:dup), i)
    end
    maximum_crosses = crosses.max || 0
    maximum_crosses + 1
  else
    0
  end
end

N = ARGV[0].to_i
matrix_of_zeros = N.times.map{ [0]*N }

puts maximum_crosses_to_place(matrix_of_zeros)

Haskell, 143 bytes
In some ways this is not done, but I had fun so here goes:

Because checking for the horizontal "winning" pattern returns invalid if applied across different rows, input of N<3 returns 0
The "arrays" are integers unpacked into bits, so easily enumerable
((i ! x) y) gives the ith bit of x times y, where negative indices return 0 so the range can be constant (no bounds checking) and fewer parentheses when chained
Because the bounds are not checked, it checks 81*4=324 patterns for every possible maximum, leading to N=3 taking my laptop 9 seconds and N=5 taking too long for me to let it finish
Boolean logic on 1/0 is used for T/F to save space, for example (*) is &&, (1-x) is (not x), etc.
Because it checks integers instead of arrays, (div p1 L)==(div p2 L) is needed to make sure a pattern isn't checked across different rows, where L is the row length and p1, p2 are positions
The value of a possible maximum is its Hamming Weight

Here's the code:
r=[0..81]
(%)=div
s=sum
i!x|i<0=(*0)|0<1=(*mod(x%(2^i))2)
f l=maximum[s[i!x$1-s[s[1#2,l#(l+l),(l+1)#(l+l+2),(1-l)#(2-l-l)]|p<-r,let  a#b=p!x$(p+a)!x$(p+b)!x$s[1|p%l==(p+mod b l)%l]]|i<-r]|x<-[0..2^l^2]]


text:
The Rien Number
The Champernowne constant is a number that is constructed by concatenating the first n numbers, with n tending to infinity. It looks something like this:
0.123456789101112131415161718192021222324252627282930...

Now, I will describe to you the Rien number. It can be thought of as a minimization of the Champernowne constant as an integer. I will refer to the Rien number with the first n digits as Ri(n). This is how to formulate it:

The first n natural numbers (the sequence {1,2,3,...}) are concatenated.
This result is then sorted, according to the digit value. So 1..12 would look like 011111223456789.
Since the Rien number cannot have leading zeroes, we move all 0s so that they are significant, whilst keeping the number minimized, resulting in, say, 101111223456789. This is Ri(n), in this case, Ri(12).

Here are some results for Ri(n):
n    Ri(n)
1    1
2    12
3    123
7    1234567
9    123456789
10   10123456789
15   101111111223344556789
34   10001111111111111222222222222223333333334444555666777888999
42   100001111111111111122222222222222233333333333333444444455556666777788889999
45   100001111111111111122222222222222233333333333333344444444444555556666777788889999
55   10000011111111111111122222222222222223333333333333333444444444444444455555555555566666777778888899999
100  100000000000111111111111111111112222222222222222222233333333333333333333444444444444444444445555555555555555555566666666666666666666777777777777777777778888888888888888888899999999999999999999
999  100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999

Objective Given a number 1 ≤ n < 10000 as input (via arguments, STDIN, or hardcoding if your language does not support conventional input), output/return Ri(n).
This is a code-golf, so the shortest code in bytes wins. You may use a language that was made after this contest, as long as it was not made for answering this challenge. (Of course, you can use it, if it provides an interesting solution, but mark your answer as non-competing.)
Reference implementation
I tested this in IE, so there really shouldn't be a problem. If there is a problem, there's an easy solution: get a sane browser.

function min(n) {
  var seq = [];
  for(var i = 1; i <= n; i++) seq.push(i);
  seq = seq.join("").split("").map(Number);
  var to;
  if(seq.indexOf(1) >= 0) to = seq.splice(seq.indexOf(1), 1);
  seq.sort(function(a, b) {
    return a - b;
  });
  if(to) seq = to.concat(seq);
  return seq.join("");
}
t.onchange = t.onkeyup = function() {
  h.innerHTML = min(this.value)
}
* {
  font-family: Consolas, monospace;
}
input {
  border: 2px dotted #aaaaaa;
  border-radius: 5px;
  margin: 10px;
}
<input id="t" type="number">

Leaderboard
The Stack Snippet at the bottom of this post generates the catalog from the answers a) as a list of shortest solution per language and b) as an overall leaderboard.
To make sure that your answer shows up, please start your answer with a headline, using the following Markdown template:
## Language Name, N bytes

where N is the size of your submission. If you improve your score, you can keep old scores in the headline, by striking them through. For instance:
## Ruby, <s>104</s> <s>101</s> 96 bytes

If there you want to include multiple numbers in your header (e.g. because your score is the sum of two files or you want to list interpreter flag penalties separately), make sure that the actual score is the last number in the header:
## Perl, 43 + 2 (-p flag) = 45 bytes

You can also make the language name a link which will then show up in the snippet:
## [><>](http://esolangs.org/wiki/Fish), 121 bytes

var QUESTION_ID=68685,OVERRIDE_USER=44713;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;
body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px}
 <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

I always thought 0 is the rien number.

Not sure if I'm missing something, but we can just move one of the 1s in front of the 0s, yeah?

@FryAmTheEggman You are correct.

@MartinBüttner \o/ you found it.

@CᴏɴᴏʀO'Bʀɪᴇɴ Nope that one was different. That one only allowed permutations of the entire numbers, not of their individual digits.

@MartinBüttner *You found my inspiration. Maybe I should submit on OEIS on this?

@CᴏɴᴏʀO'Bʀɪᴇɴ Sure why not.

Shouldn't the output for input 10 be 10123456789?

@Zach gates yes, my mistake

@flawr I agree. :D

Pyth, 8
+1SjktSQ

Makes a list [1, .. , input] then removes the leading one, joins and sorts, then prepends a 1.
Test Suite

Perl, 44 42 41 33 31 bytes
Yaaay, first post ever !
Thanks to primo for the 2 bytes save.
print 1,sort"@{[2..<>]}"=~/\d/g

As others did, removing 1 and prepending it manually does the work.
Try it online

Welcome to PPCG, and congrats on your first post (though it seems strange having me welcome you, since you joined before I did ...). Two things -- I count 43 bytes ... second, your "Try it online" link looks to point to an older/different revision of your code. Manually copy-pasting your code into Ideone works, but not your link.

Thank you for you comment ! I used TextWrangler for the byte count, guess I went 1 too far... (plus a space wasn't needed, so that reduces the whole bytecount to 42). The Ideone should be fixed now.

Oh, didn't know about that. Also works on my Perl on my Mac (5.18) Thanks !

Crossed out 44 is still regular 44 ;(

Haha, I didn't know about that meme ! I read a lot of challenges and answers before posting, but I never noticed that :p

Saved two bytes by getting rid of the split/join: print 1,sort"@{[2..<>]}"=~/\d/g

Didn't know you could use the regexp to split the number. Nice find !

Japt, 14 12 bytes
1+2o°U ¬¬n ¬

Try it online!
How it works
1+2o°U ¬¬n ¬  // Implicit: U = input integer
  2o°U        // Generate the range of integers from 2 to U, inclusive.
       ¬¬     // Join, then split into chars.
         n    // Sort.
1+         ¬  // Join again, and add a 1 to the beginning.
              // Implicit: output last expression

o_o you golfed it in the 5 minute grace period? [tag:fastest-gun-in-the-west]

@CᴏɴᴏʀO'Bʀɪᴇɴ I'm guessing you don't want to post new code golfs after that :D

Retina, 78 bytes
Time to show off some new Retina features (it's still not very competitive, but before today this would probably have been closer to 300 bytes).
.+
$0$*1
\B
 $`
(1)+
$#1
^1|

.
 1$0$*1
+r`(1+\2) (1+)\b
$2 $1
 1(1)*
$#1
^
1

Try it online.
Explanation
While it's possible to convert between decimal and unary quite conveniently now, this is still quite long because I have to convert back and forth several times because some operations are more doable in decimal than in unary and vice-versa.
.+
$0$*1

Let's start by converting the input to unary. This works by matching the input and then using $*1 which repeats 1 that many times (this repetition feature is new as of today).
\B
 $`

Next, we generate a range from 1 to N in unary. I've explained why this works in my FizzBuzz answer.
(1)+
$#1

We convert each number in the range back to decimal so we can work with the decimal digits. This is done by matching each of the unary numbers such that each 1 generates a separate capture. Then we replace that with the number of captures of group one, using the new capture count syntax $#1.
^1|

This removes the leading 1 as well as all spaces from the string so we're left with only the digits (except for a single 1).
.
 1$0$*1

We convert back to unary and add 1 to each digit (to ensure that even 0 is a non-empty). We also insert a space in front of each digit to ensure that they are separated.
+r`(1+\2) (1+)\b
$2 $1

We repeatedly match a small number preceded by a larger number and swap them. That's bubble sort in Retina. :)
 1(1)*
$#1

Aaaand back to decimal.
^
1

Finally, we insert a single 1 at the front to account for the one we've removed earlier.

What new features do ye speak of?

@CᴏɴᴏʀO'Bʀɪᴇɴ I'll add an explanation later. This one uses new substitution syntax for counting captures and repeating characters which can be used for reasonably short decimal/unary conversion. Here is the full changelog: https://github.com/mbuettner/retina/blob/master/CHANGELOG.md

@MartinBüttner nice.  Does this mean Retina can no longer claim this exemption?

@DigitalTrauma I think it's still the most natural form of input. Also I never understood how that kind of language-ism ever got so much support on this site.

Haskell, 44 bytes
import Data.List
f n='1':sort(show=<<[2..n])

Unfortunately sort is in Data.List, that's 17 bytes!

JavaScript (ES6), 65 62 54 52 bytes
Saved 3 bytes thanks to edc65
x=>eval("for(b='';x>1;)1+[...b+=x--].sort().join``")

Builds a string of all numbers from 2 to x, then splits, sorts, joins, and adds a 1 to the beginning. This may still be golfable; suggestions welcome!

I don't have ES6 on hand, but can't you just use (new) Array(x-1).map((_,y)=>y+2)?

@CᴏɴᴏʀO'Bʀɪᴇɴ map skip empty array elements, so you should use Array(n).fill().map(... (see ES6 tips)

Too late to post mine, but a hint for you: n=>1+[...[...Array(n-1)].map(_=>++n,n=1).join``].sort().join``  (1 byte shorter, it's the split)

@edc65 and Cᴏɴᴏʀ O'Bʀɪᴇɴ Thanks for the tips! I wondered why using .split() felt so odd...

@edc65 Huh, is my solution the same length as yours: n=>1+[...[...Array(n+1).keys()].slice(2).join\`].sort().join```

CJam, 9
1qi),2>s$

Try it online
Alternatively:
qi,:)(\s$

APL (17)
'1',∆[⍋∆←1↓∊⍕¨⍳⎕]

Explanation:
'1',∆[⍋∆←1↓∊⍕¨⍳⎕]
-----------------
               ⎕   read a number from the keyboard
               ⍳    get the natural numbers up to and including that number
             ⍕¨    get the string representation for each number
           ∊       flatten the array (giving a string of digits)
         1↓        remove the first digit (which is always 1)
       ∆←          store the result in ∆
      ⍋            get a permutation to sort ∆ upwards
    ∆[           ] rearrange ∆ so that it is sorted
'1',               add a 1 to the front

Test:
      '1',∆[⍋∆←1↓∊⍕¨⍳⎕]
⎕:
      1
1
      '1',∆[⍋∆←1↓∊⍕¨⍳⎕]
⎕:
      10
10123456789
      '1',∆[⍋∆←1↓∊⍕¨⍳⎕]
⎕:
      55
10000011111111111111122222222222222223333333333333333444444444444444455555555555566666777778888899999

Nice! Much better than mine. :D I didn't realize that ∊ would flatten the array and give you a string. That's good to know.

Mathematica, 52 bytes
"1"<>ToString/@Sort[Join@@IntegerDigits[2~Range~#]]&

Once again, string processing happened...

I think IntegerDigits threads over lists so you don't need map it.

Oh right, precedence.

Bash, 35 34 bytes
printf %d 1`seq 2 $1|fold -1|sort`

This builds on the answers of @DigitalTrauma and @OlivierDulac. Try it online with Ideone.
How it works

seq 2 $1 prints all integers from 2 to the one specified on the command line.
fold -1 wraps all lines with width 1, i.e., places each character on its own line.
-1 seems to be an undocumented feature.
sort sorts the characters by their numeric value.
printf %d 1`...` prepends a 1 to the first line and prints each line as an integer (%d), with no separation.
This takes advantage of Bash's curious printf implementation, which repeats the format string over and over, until all arguments are consumed.

+1, I like that one better than ours :)

Bash + GNU utilities, 58
seq $1|sed 's/./&\n/g'|sort|tr -d \\n|sed 's/\(0*\)1/1\1/'

Try it online.

I had a similar approach, but a different handling of the "1 at beginning" part (52 bytes). With yours, you can shave off : sort (1 digit long, no need for -n).

Jelly, 8 bytes
RDFṢ1œ|Ḍ

Try it online!
How it works
RDFṢ1œ|Ḍ  Main link. Argument: n (integer)

R         Range; yield r := [1, ..., n].
 D        Convert each k in r into the array of its digits in base 10.
  F       Flatten the resulting array of lists.
   Ṣ      Sort the resulting flat list of digits.
    1œ|   Perform multiset union with 1 as left argument.
          This moves a single 1 to the beginning of the list.
       Ḍ  Convert the resulting list of base 10 to integer.

JavaScript ES6, 49 46 Bytes
Thanks to edc65 for 2 bytes

F=
x=>1+[...(g=_=>x>1?x--+g``:_)``].sort().join``

;console.log(F(15))

I got something similar but 1 byte shorter. Try using a recursive function with no argument, just decreasing the original parameter x

Jelly, 6 bytes
ḊVṢ1;Ḍ

Try it online!
-1 thanks to Unrelated String
Ḋ      # Dequeue (Remove head from implicit range)
 V     # Eval (Jelly stringifies each, concatenates & evals, which does exactly what I want)
  Ṣ    # Sort
   1;  # Prepend a 1
     Ḍ # Decimalify, convert into base-10 number

PowerShell, 61 59 bytes
param($a)(("1"+-join([char[]]-join(2..$a)|sort)),1)[$a-eq1]

Takes input param($a) and then uses it to index into an array with [$a-eq1]. If true, we index the second element and output 1. Otherwise, we concatenate "1" with the joined array created by 1) defining a new range 2..$a that has been itself joined together, 2) casting that as a char-array, and 3) sending it through the Sort-Object cmdlet, all of which is then output.
Edit1 -- Saved 2 bytes by moving the inner -join operator.

Python 2, 60 bytes
_="".join;print"1"+_(sorted(_(map(str,range(2,input()+1)))))

ClojureScript, 48 bytes
#(apply str"1"(sort(apply str(range 2(inc %)))))

Same as all of the others, pretty much.  REPL available here.

Smalltalk, 76 bytes
As usual in Smalltalk, conceptually very terse, but textually very verbose...
f:l^'1',((2to:l)fold:[:p :q|p asString,q asString])asByteArray sort asString

Add this as a class method for String and call like this, e.g. for 20, String f: 20

Ruby, 48 bytes
An anonymous function. Basically just Rubyfied some of the other answers here..
->n{n>1?(?1+[*2..n].join.chars.sort*'').to_i: n}

Milky Way 1.6.4, 22 bytes (not competing)
^^'LH=^^JB", "-Q"1";+!

I had to add a sorting opcode for this challenge.

Explanation
^^                      ` pop the TOS
  '                     ` read input from the command line
   LH                   ` push a reversed Pythonic range(TOS+1)
     =^^J               ` remove the top 2 items from the TOS
         B              ` push the string literal of the TOS
          ", "-         ` remove ", " from the TOS
               Q        ` sort the TOS
                "1";+   ` add "1" to the beginning of the TOS
                     !  ` output the TOS

MATL, 17 bytes
Uses current version (7.0.0) of language/compiler.
49[]i:"@YUh]6L)Sh

Inspired by FryTheEgggman's answer.
EDIT (July 29, 2016): You can try it online with some modifications to conform to changes in the language.
Example
>> matl
 > 49[]i:"@YUh]6L)Sh
 >
> 12
101111223456789

Explanation
49        % push '1'
[]        % push empty array
i:        % input "N" and build vector [1, 2, ... N]
"         % for each number in this vector
   @      % push that number
   YU     % convert to string
   h      % concatenate horizontally
]         % end
6L)       % remove first element
S         % sort
h         % concatenate horizontally

Brachylog, 76 41 bytes
1 .;{,1:.e?}?:1fcbZlL,ZoOlM,10^(L-M)=:Oc.

Takes a number as input.
This solution works with the few changes I made to the built-in Findall predicate f.  OP is apparently OK with using languages older than the answer so I think this is fine (the changes I made were intented a long time ago, I just motivated myself to do it because of this challenge).
Explanation
1 .                                            § If the input is 1, unify output with 1

   ;                                           § Else

    {      }?:1f                               § Output a list of all inputs which satisfy
                                               § the predicate in brackets with the input
                                               § of the main predicate (ie the input number)
                                               § as output

     ,1:.e?                                    § True if the input is an integer between 1
                                               § and . (the output)

                cbZ                            § Concatenate everything into a single number,
                                               § remove the first digit (1) and call it Z

                   lL,ZoOlM,                   § L is the length of Z, M is the length of O
                                               § O being Z sorted (which removes the leading
                                               § 0s)

                            10^(L-M)=:Oc.      § Concatenate 10^(L-M) at the beginning of O
                                               § and unify it with the output

Bash and GNU tools, 58 52 bytes
echo 1$(seq 2 $1|sed -e 's/./&\n/g'|sort|tr -d \\n)

similar approach than @Digital-trauma , but different way to add the 1, and no need for -n as numbers are 1 digit long. (I saw his answer after I did my first try)

Gogh, 9 7 bytes
GJT1-1P

You can run this using:
$ ./gogh noi 'GJT1-1P' <input>

G     “ Push a range (1, TOS]       ”
J     “ Join the TOS                ”
T     “ Sort the TOS                ”
1-    “ Remove the first 1          ”
P     “ Prepend the TOS to the STOS ”

"You may use a language that was made after this contest, as long as it was not made for answering this challenge." I allow such languages to be competitive in my challenges, usually ;)

@CᴏɴᴏʀO'Bʀɪᴇɴ: Oh, awesome! Thanks for pointing that out :)

Oracle SQL 11.2, 222 211 bytes
SELECT 1||TRIM(xmlagg(xmlelement(e,c)).EXTRACT('//text()'))FROM(SELECT SUBSTR(s,LEVEL+2,1)c FROM(SELECT MAX(sys_connect_by_path(LEVEL,' '))s FROM DUAL CONNECT BY LEVEL<=:1)CONNECT BY LEVEL<=LENGTH(s)ORDER BY 1);

Un-golfed
SELECT 1||TRIM(xmlagg(xmlelement(e,c)).EXTRACT('//text()'))  -- add leading 1, concatenate each char and remove spaces
FROM   (
         SELECT SUBSTR(s,LEVEL+2,1)c                          -- split the string in characters, omiting the first number (1)
         FROM   (
                  SELECT MAX(sys_connect_by_path(LEVEL,' '))s -- create a string by concatenating numbers
                  FROM   DUAL
                  CONNECT BY LEVEL<=:1
                )
         CONNECT BY LEVEL<=LENGTH(s)ORDER BY 1
       )

Vyxal R, 4 bytes
ḣṅs+

Try it Online! -2 thanks to Lyxal.
ḣ    # Implicitly convert to [1...n], then push 1 and [2...n]
 ṅ   # Concatenate [2...n] into a string
  s  # Sort
   + # Prepend the 1 from before

Try it Online! for 5 bytes nowadays

TI-Basic, 77 bytes
Input N
{0
For(I,2,N
augment(Ans,int(10fPart(I/seq(₁₀^(J),J,1,1+int(log(I
End
Ans→A
SortD(ʟA
1→ʟA(dim(ʟA
.1sum(seq(₁₀^(I)ʟA(I),I,1,dim(ʟA

Output is stored in Ans as a number and is displayed. Does not work for inputs that are 55 and above because of overflow errors.

87 bytes
Input N
{0
For(I,2,N
augment(Ans,int(10fPart(I/seq(₁₀^(J),J,1,1+int(log(I
End
Ans→A
SortA(ʟA
"1
For(I,2,dim(ʟA
Ans+sub("0123456789",ʟA(I)+1,1
End

Output is stored in Ans as a string. Works with higher inputs than the above method could, depending on how much free RAM there is. sub("0123456789",ʟA(I)+1,1 can be replaced with toString(ʟA(I to save 18 bytes if it is run on a TI-84+ CE OS 5.2+.

Nekomata, 8 bytes
RtƊjo1cɗ

Attempt This Online!
RtƊjo1cɗ
R           Range [1, input]
 t          Tail; remove the first element
  Ɗ         Convert to lists of decimal digits
   j        Join
    o       Sort
     1c     Prepend 1
       ɗ    Convert from a list of decimal digits

Julia, 33 bytes
n->"1"*join(sort([join(2:n)...]))

This is a lambda function that accepts an integer and returns a string. To call it, assign it to a variable.
We construct the range 2:n, which will be empty for n < 2, join it into a string, splat the string into an array of characters, sort them, join it into a string, and prepend 1.

APL, 21 bytes
{' '~⍨⍕1,x[⍋x←⍕1↓⍳⍵]}

This is an unnamed monadic function that accepts an integer on the right and returns a string. To call it, assign it to a variable.
Explanation:
            x←⍕1↓⍳⍵]}   ⍝ Get the numbers 1:input, drop 1, convert to string
         x[⍋            ⍝ Sort
      ⍕1,               ⍝ Tack 1 onto the front, flatten to string
{' '~⍨                  ⍝ Remove the spaces (side effect of ⍕ on an array)

Try it online

Python 2, 60 bytes
P=input();print"1"+"".join(sorted(`range(2,P+1)`)[P*2-4:-2])

Indexing for the win. :-)

Python 2, 60 bytes
P=input();print"1"+"".join(sorted(`range(-P,-1)`))[P*3-5:-2]

Just an alternative.

Seriously, 10 bytes
,u2xεjS'1+

Hex Dump:
2c753278ee6a5327312b

Try It Online
Explanation:
,            Read input
 u2x         Push range from 2..n
    εj       Join into string
      S      Sort
       '1+   Prepend a "1"

05AB1E, 6 bytes
Note: This submission uses features that postdate this challenge and is therefore not competitive
Code:
Lß?J{?

Explanation:
L      # Creates the list [1 .. input]
 ß     # Extract the smallest value of the list
  ?    # Print this value (always 1)
   J   # ''.join(list)
    {  # Sort the string
     ? # Print this value

Uses ISO 8859-1 encoding

How does this work?

@ThomasKwa Explanation added

Whoa. This is fantastic!

Mathcad, 86 "bytes"
The function s(n) uses a for loop to build up the Champernowne "integer" by converting each number to its string form and concatenating them together.  The string is then converted to its equivalent vector of ASCII codes and sorted. The function then swaps any leading zeros with the first one, finally converting the vector back to a string.
To check the function, I put the test cases into a vector vn, then applied s to vn using the vectorize operator.  I then check the results against the given test case values.

Mathcad is mathematical application based on 2D worksheets comprised of "regions" each of which can be text, a mathematical expression, program, plot or scripted component.
A mathematical or programming instruction is picked from a palette toolbar or entered using a keyboard shortcut. For golfing purposes, an operation ("byte") is taken to be the number of keyboard operations necessary to create a name or expression (for example, to set the variable a to 3, we would write a:=3.  The definition operator := is a single keypress ":", as are a and 3 giving a total of 3 "bytes".  The programming for operator requires typing ctl-shft-# (or a single click on the programming toolbar) so again is equivalent to 1 byte.

Reng v.3.2, 36 bytes
1i#x:xe!Ø;$:1+)å(Eh
å'11µ1nran! ¡n~

Try it here!
This pushes 1 to the stack, then stores the input i into x (i#x). Then, a range of all the necessary numbers is created using :xe!Ø;$:1+)å(Eh, being ended by Ø, which goes the first i.e. next line. å takes every number and pushes the digits of that number.
On the next line, å breaks the last number into its digits, ' sorts the stack, and 11µ removes 1 1 from the stack. A 1 is then printed, and the numbers are reversed then outputted through the loop an! ¡n. The program is terminated with ~.

Maybe you could add an explanation about this?

@HannesKarppila I have added an explanation.

Seriously, 10 bytes
,Rp@εjS@$+

Try it online!
Explanation:
,Rp@εjS@$+
,Rp@        push range(1, input()+1), pop first element (1), swap
    εjS     join list on empty string, sort
       @$+  prepend the 1

Pyke, 9 bytes, noncompetitive
Stm`sS1R+

Explanation:
S         -      range(1,inp+1)
 t        -     ^[1:]
  m`      -    map(str,^)
    s     -   sum(^)
     S    -  sort(^)
      1R+ - 1+^

Try it here!

Stacked, 22 bytes
2\|>''join sorted'1'\+

Try it here! Expects input on TOS. Example on the repl:
> 15
(15)
> 2\|>''join sorted'1'\+
('101111111223344556789')

Explanation
2\|>''join sorted'1'\+
2\|>                    range from 2 to n
    ''join              join by empty string
           sorted       sort it
                 '1'\+  and prepend a '1'

A more fun version:
Stacked, 45 bytes
{*x:1[1+:yield]x 1-*}!toarr''join sorted'1'\+

Expects input as TOS. For example (on the repl):
> 15    (* the input *)
(15)
> {*x:1[1+:yield]x 1-*}!toarr''join sorted'1'\+
('101111111223344556789')
>

Explanation
{*x:1[1+:yield]x 1-*}!toarr''join sorted'1'\+
{*x:1[1+:yield]x 1-*}                            generator function that...
  x:                                               given x
    1                                              pushes 1
     [        ]x 1-*                               and executes the inside (x-1) times:
      1+                                             adds 1 to the TOS (initially 1);
                                                     2 is the first value yielded
        :yield                                       and yields it for the generator
                     !                           initialize this generator with TOS
                      toarr                      exhaust generator into an array
                           ''join                join by empty strings
                                  sorted         sort the values
                                        '1'\+    prepend '1'.

C (gcc), 172 161 158 156 bytes

Saved eleven fourteen sixteen bytes thanks to ceilingcat.

f(n){char*z,s[++n];int d[10]={0},j=1,k=0;for(;sprintf(s,"%d",j),j++<n;)for(z=s;*z;)d[*z++-48]++;for(d[printf("1")]--;k<10;)for(j=d[k++];j--;putchar(k+47));}

Try it online!

Japt, 8 bytes
ô ¤¬ñ i1

Try it
ô ¤¬ñ i1     :Implicit input of integer
ô            :Range [0,input]
  ¤          :Slice off the first 2 elements
   ¬         :Join
    ñ        :Sort
      i1     :Prepend 1

Thunno 2 O, 5 bytes
RḢ¢JṠ

Try it online!
Explanation
RḢ¢JṠ  # Implicit input
R      # Push the range [1..input]
 Ḣ     # Extract first item (1)
  ¢    # Print without newline
   J   # Join the list
    Ṡ  # Sort the resulting string
       # Implicit output

Lua, 102 Bytes
How can lua be so long while all other entries are < 30 bytes... I'm sure even Java would be shorter!
t={}for i=2,...do(i..''):gsub(".",function(d)t[#t+1]=d end)end
table.sort(t)print(1 ..table.concat(t))

Ungolfed
t={}                           -- initialise t as a table
for i=2,...                    -- iterate from 2 to n
do
  (i..''):gsub(".",function(d) -- iterate over each digits in i
    t[#t+1]=d                  -- insert the digit into t
  end)
end
table.sort(t)                 -- sort t
print(1 ..table.concat(t))    -- prepend a 1 to the content of t separated by ''

I'm forced to put a space in print(1 .., else it would try to evaluate it to a decimal 1.<decimal part>, and throws an error because . isn't a valid decimal part.

Attache, 20 bytes
{"1"+Sort!Join[2:_]}

Try it online!
The point-free version is actually 1 byte longer: "1"&`+@Sort@Join@2&`:. This works as most of the other answers do.

Husk, 8 bytes
:'1Oṁs…2

Try it online!
Corrected my previous answer.

Java (JDK), 153 151 bytes
i->{var s="";for(int j=0;j++<i;)s+=j;var c=s.toCharArray();java.util.Arrays.sort(c);return new String(c).replaceFirst("1","0").replaceFirst("^.","1");}

Try it online!
-2 Thanks to Ceilingcat!

Oh right, I always use that but then realize that it doesn't work (as it increments before the first iteration) though here I can abuse that fact.

Suggest getBytes() instead of toCharArray()

Ly, 19 bytes
n[sSl,]ppar1y[fu,]p

Try it online!
n                    - read count of numbers to use from STDIN
 [s l,]              - loop that many times, using backup cell to save loop var
   S                 - push digits of "int" at the top of the stack
       pp            - drop "0" and "1" from the stack
         ar          - sort digits, reverse stack
           1         - push "1" onto the stack
            y        - push the stack size onto the stack
             [  ,]   - loop over over stack, use backup cell for loop var
              fu     - flip loop var and digit, print digit
                  p  - delete loop var

R, 60 bytes
a=\(n)cat(1,sort(unlist(strsplit(c("",1:n)[-2],""))),sep="")

PowerShell Core, 44 bytes
"1"+-join(1.."$args"-ne1|%{"$_"|% t*y}|sort)

Try it online!
"1"+-join(1.."$args"-ne1|%{"$_"|% t*y}|sort)
"1"+                                          # Always return a 1
          1.."$args"-ne1|%{"$_"|% t*y}|sort   # Generate a range from 2 to the $a, convert to characters, sort them
    -join(                                 )  # Join them into a string

Created with the help of Luminespire.

Raku, 46 bytes
{{S/(0*)(.)/$1$0/}([~] ([~] 1..$_).comb.sort)}

Try it online!

Ruby, 73 bytes
n,s=gets.to_i,"";(2..n).each{|i|s+=i.to_s};p ("1"+s.chars.sort.join).to_i
Attempt This Online!


text:
Output the next kana
Japanese kana characters correspond to a single sound in the Japanese language. With the exception of ん (n), every other kana consists of a consonant part and a vowel part. There is a natural ordering to Japanese kana, a sort of "alphabetical order", which is typically arranged in a 10 by 5 table:
   |   a    i    u    e    o
-----------------------------
*  |   a    i    u    e    o
k  |  ka   ki   ku   ke   ko
s  |  sa   si   su   se   so
t  |  ta   ti   tu   te   to
n  |  na   ni   nu   ne   no
h  |  ha   hi   hu   he   ho
m  |  ma   mi   mu   me   mo
y  |  ya        yu        yo
r  |  ra   ri   ru   re   ro
w  |  wa                  wo

This ordering is called gojuuon, or "fifty sounds", even though some of the fifty cells in the table are in fact empty.
The challenge
Input will be any of the listed kana above, with the exception for wo. Your program or function should output the next kana along in left-to-right, top-to-bottom reading order, e.g:
Input       Output
------------------
a     ->    i
i     ->    u
o     ->    ka
ke    ->    ko
so    ->    ta
ni    ->    nu
ya    ->    yu
yu    ->    yo
wa    ->    wo
wo    ->    (undefined behaviour)

With the exception of an optional single trailing newline, there should be no leading or trailing whitespace in the output.
This is code-golf, so the goal is to minimise program size, in bytes.
Additional notes

In order to keep things simple, this challenge uses Nihon-shiki romanisation. Hepburn romanisation is more common, but has a few kinks which make things more annoying for golf (e.g. si becomes shi, hu becomes fu).
Kana do exist for the empty spots (see Japanese SE), but they were either non-standard or are now obsolete.

I think it would be much more fun to use the Hepburn exceptions and make wo transform to n which loops to a.

Retina, 54 53 bytes
T`au`ie`y.
wa
we
T`\oeuia`ao
T`ko`stn\hmyr\w`.a
^a
ka

Try it online.
Explanation
Wooo, showing off even more features from today's 0.7.2 release. :) (The release predates this challenge by about 7 hours.)
T`au`ie`y.

This is a transliteration which replaces a with i and u with e, but only in matches of y.. The purpose of that is to treat ya and yu like yi and ye, respectively, in order to skip the gaps.
wa
we

Replace wa with we to skip that gap as well.
T`\oeuia`ao

Here is the new feature. When rotating sets of characters, the "from" and "to" set in a transliteration are usually almost identical. So now we've got o (without a backslash) to refer to the other set, which allows us to get rid of some duplication. The \o just stands for a literal o in that case. So the two sets expand to:
oeuia
aoeuia

The extraneous a in the second set is ignored and the vowels are replaced cyclically as expected.
T`ko`stn\hmyr\w`.a

This does the same thing for the consonants, but using o in the first set (just because we can...). h and w need escaping because they are character classes. The expanded sets are:
kstnhmyrw
stnhmyrw

The .a restricts this operation to syllables that end in a, i.e. those that wrap to the next line of the table.
^a
ka

Finally, we replace a single a with ka, because that case cannot be handled by the previous transliteration.

Doesn't using a version of your language released after the challenge was posted disqualify your entry from competing? (Guess why I asked about this in that other place? ;)

@Alex I released that version before this challenge was posted.

Okay. My apologies. Your edit made it appear otherwise. I just verified your list of releases (probably should've done that before throwing accusations around).

Pyth, 42 40 38 bytes
s.r]z.DrR6*" kstnhmyrw""aiueo"CM"$&./0

This takes the outer product between vowels and consonants, and removes elements at the ords of each number in $&./0. Then it outputs the element after the input.
@J.DrR6*" kstnhmyrw""aiueo"CM"$&./0"hxJz    Implicit: z=input()
       *" kstnhmyrw""aiueo"                 Outer product: [' a',...,' o','ka',...]
    rR6                                     Strip each string—'a'~'o' now single letters
                           CM"$&./0"        Map ord onto the string: [36,38,46,47,48]
  .D                                        Remove elements at those indices.
 J                                          That's the list of kana; assign it to J
                                     xJz    Find the index (x) of z in J,
                                    h       add one,
@J                                          and access J at that index.

Try it here.

Wow, this language is crazy!

GNU sed, 65
Comments not included in score:
:                        # Define unnamed label
y/aiueo/iueoa/           # Rotate vowels
/a/y/kstnhmyr/stnhmyrw/  # If at end of row, rotate consonants
s/^a/ka/                 # If at end of 1st row, prefix a "k"
/[yw][ie]\|wu/b          # If one of the invalid values, jump back to label and redo

Oy, this is beginning to look a lot like @Martin's Retina answer (but longer, of course).

Ruby, 105
->n{a=['wo','wa']
'rymhntsk '.chars{|c|a+='*o *e *u *i *a'.tr(?*,c).split}
a[8..10]='yu'
a[a.index(n)-1]}

Commented in test program
f=->n{a=['wo','wa']                     #initialize array to last line of table, begin to build table backwards
  'rymhntsk '.chars{|c|                 #for each consonant,
    a+='*o *e *u *i *a'.tr(?*,c).split  #perform a sustitution to get that line of table in string form,
  }                                     #then split into array at spaces and append to a
  a[8..10]='yu'                         #substitute 3 elements ye yu yi with 1 element yu
  a[a.index(n)-1]                       #return element before argument (array is backwards.)
}

puts f[gets.chop]

You can save a few bytes with a=%w{wo wa}.

Also: "rymhntsk ".chars{|c|"oeuia".chars{|d|a<<c+d}}, although I have a sneaking suspicion it could be golfed further.

TXR Lisp, 135 127 124 91 bytes
(ret[(memqual @1(diff(maprod(op trim-str`@1@2`)" kstnhmyrw""aiueo")'#"yi ye wi wu we"))1])

Run:
1> (ret[(memqual @1(diff(maprod(op trim-str`@1@2`)" kstnhmyrw""aiueo")'#"yi ye wi wu we"))1])
#<interpreted fun: lambda (#:arg-1-0208 . #:arg-rest-0207)>
2> [*1 "a"]
"i"
3> [*1 "o"]
"ka"
4> [*1 "ki"]
"ku"
5> [*1 "mu"]
"me"
6> [*1 "ya"]
"yu"
7> [*1 "yo"]
"ra"
8> [*1 "wa"]
"wo"

JavaScript, 145 162 131 118 bytes
x=>(d=" kstnhmyrw".replace(/./g,"$&a$&i$&u$&e$&o").replace(/ |yi|ye|wiwuwe/g,"").match(/[^aiueo]?./g))[d.indexOf(x)+1]

Admit it, you couldn't imagine a more ridiculous solution to solve this problem ;) ok, done this in a more interesting way.
Demo:

function p(x) {
  return (d=" kstnhmyrw".replace(/./g,"$&a$&i$&u$&e$&o") //build the sequence of kana, regex rulez!
        .replace(/ |yi|ye|wiwuwe/g,"")                   //remove the spaces and excess kana
        .match(/[^aiueo]?./g))[d.indexOf(x)+1]           //split it into array using regex and get the index of input in it
}

alert(p(prompt()))

@Sp3000 Oh, that's a pity, you should then mention that these excess (trailing/leading) spaces ain't allowed.

@nicael I don't see anything in the spec implying that they are currently allowed.

@Sp3000 fixed spacing.

Bash + sed, 83
echo {,k,s,t,n,h,m,y,r,w}{a,i,u,e,o}|sed -E "s/[yw][ie]|wu//g;s/.*\b$1 +//;s/ .*//"

Brace expansion to create full table on one line
sed to:

remove yi, ye, wi, wu and we
remove everything up to and including the input entry (but not the next entry)
remove everything after the next entry

Haskell, 114 96 bytes
f"ya"="yu"
f"yu"="yo"
f"wa"="wo"
f x=snd(span(/=x)[words[a,b]!!0|a<-" kstnhmyrw",b<-"aiueo"])!!1

[words[a,b]!!0|a<-" kstnhmyrw",b<-"aiueo"] is a list of all kanas, including the "holes". I break up the list into the part before the input kana and from the input kana up to the end. From the 2nd part I pick the second element. The exceptions around the "holes" a caught before by separate cases.
Edit: @xnor came up with the idea of using spanwhich saved 18 bytes.

Would something like (snd$span(/=x)k)!!1 not work for the lookup?

@xnor: now that I see it, it's obvious. Thanks so much!

Japt, 75 70 68 bytes
X=" kstnhmyrw"£"aiueo"®+X w} r" |yi|ye|wiwuwe"P f"[^aiueo]?.")g1+XbU

Try it online!

Pretty nice! I tried to golf this down more, but I could only chop off 3 bytes: X=" kstnhmyrw"£"aiueo"mZ{X+Z} } r" |yi|ye|wiwuwe"P f"[^aiueo]?.")g1+XbU

@Eth yeah, and also you've got an excess space in } } :)

Ohhhh right, I forgot that was automatically added :)

@Eth look, we can get it two bytes shorter with your magic shortcuts :D

Wait, that actually works? Nice, you've outgolfed me ;)

@Eth note, w, otherwise obviously doesn't ;)

Lexurgy, 115 bytes
a:
{a,i,u,e,o}=>{i,u,e,o,'a}
b:
'=>k/$ _
{',k,s,t,n,h,m,y,r,w} '=>{k,s,t,n,h,m,y,r,w,`} *
y:
{i,e}=>{u,o}/y _

Explained:
# advance the vowel
a:
{a,i,u,e,o}=>{i,u,e,o,'a}
# advance the consonant
b:
'=>k/$ _ # o => ka case
{',k,s,t,n,h,m,y,r,w} '=>{k,s,t,n,h,m,y,r,w,`} * # everything else
# force yu yo
y:
{i,e}=>{u,o}/y _

definitely the right tool for the job

Perl 6, 105 bytes
.[.first(@*ARGS[0],:k)+1].say with (" kstnhmyrw".comb X~ ).grep(* !~~/[y|w][i|e]|wu/)».trim

This is as short as I can get it on my first go, I might have another crack at it later but I feel pretty good about this.

JavaScript (ES6), 127 bytes
s=>s>"yt"?"yo":s=="ya"?"yu":s=="wa"?"wo":(m=[].concat(...["",..."kstnhmyrw"].map(c=>[..."aiueo"].map(v=>c+v))),m[m.indexOf(s)+1])

Explanation
s=>

  // Hardcode "yu", "ya" and "wa"
  s>"yt"?"yo":
  s=="ya"?"yu":
  s=="wa"?"wo":

  // Generate table
  (m=[].concat(...                                   // flatten the array of arrays
    ["",                                             // first consonant is blank
    ..."kstnhmyrw"].map(c=>[..."aiueo"].map(v=>c+v)) // combine each consonant and vowel
  ))[m.indexOf(s)+1]                                 // return the next sound

Test

var solution = s=>s>"yt"?"yo":s=="ya"?"yu":s=="wa"?"wo":(m=[].concat(...["",..."kstnhmyrw"].map(c=>[..."aiueo"].map(v=>c+v))),m[m.indexOf(s)+1])
<input type="text" id="input" value="mo" />
<button onclick="result.textContent=solution(input.value)">Go</button>

Perl 6, 96 bytes
{my @a=(" kstnhmyrw".comb X~ ).grep({!/[y|w][e|i]|wu/})>>.trim;@a[1+@a.first($_,:k)]}

C, 138 135 bytes
char*s="aiueokstnhmyrw";i,j;k(*v){j=strchr(s,*v>>8)-s;i=strchr(s,*v)-s;j=i<4?i++:j<4?j-~(2520%i&3):!++i;printf("%c%c",s[i],i<5?:s[j]);}

Wandbox

Python 2, 107 bytes
L=[(x+y).lstrip()for x in' kstnhmyrw'for y in'aiueo'if x+y not in'yiyewiwuwe']
print L[L.index(input())+1]

Expects input enclosed in quotes, 'he' for example

Racket 151 bytes
(second(member s '(a i u e o ka ki ku ke ko sa si su se so ta ti tu te to na
ni nu ne no ha hi hu he ho ma mi mu me mo ya yu yo ra ri ru re ro wa wo)))

Ungolfed:
(define (f s)
  (second
   (member s
           '(a i u e o ka ki ku ke ko sa si su se so ta ti tu te to na ni nu ne
               no ha hi hu he ho ma mi mu me mo ya yu yo ra ri ru re ro wa wo))))

Testing:
(f 'a)
(f 'i)
(f 'o)
(f 'ke)
(f 'so)
(f 'ni)
(f 'ya)
(f 'yu)
(f 'wa)

Output:
'i
'u
'ka
'ko
'ta
'nu
'yu
'yo
'wo

There is an error message if 'wo is sent.