New answers tagged

2

Charcoal, 37 bytes ≔⁺⭆χιβη¿∨¬θ⊙θ¬№ηιInvalid inputFηF№θιι Try it online! Link is to verbose version of code. Explanation: ≔⁺⭆χιβη Concatenate the digits with the lowercase letters. ¿∨¬θ⊙θ¬№ηι If the input is empty or contains a character not in the digit letter string, ... Invalid input ... then output the required error message, ... Fη ... else for ...


4

x86-16 machine code, IBM PC-DOS, 81 80 bytes Binary: 00000000: b40a ba4f 01cd 218b f2ad 8bd6 8acc 8be9 ...O..!......... 00000010: 938b f28b fe51 ad3c 307c 0c3c 397e 0e3c .....Q.<0|.<9~.< 00000020: 617c 043c 7a7e 06ba 4201 59eb 103a c47c a|.<z~..B.Y..:.| 00000030: 0286 c4ab 4e4f e2de 59e2 d688 1bb4 09cd ....NO..Y....... 00000040: 21c3 496e ...


3

Perl 5 -pF//, 45 bytes $_=/^[a-z\d]+$/?join"",sort@F:"Invalid Input" Try it online!


2

PHP, 92 bytes $a=str_split($s=$argn);sort($a);echo preg_match('/^[a-z\d]+$/',$s)?join($a):'Invalid input'; Try it online!


4

Burlesque, 37 bytes ><JJann!/^zz!=||{vv"Invalid Input"}if Try it online! >< # Sort input string JJ # Duplicate twice ann! # Not alphanumeric /^ # Swap and duplicate (sorted string) zz!= # Lowercased not equal to original (i.e. contains uppercase) || ...


3

Jelly, 18 bytes ɠfƑØBŒl¤ȧṢȯ“4{ẉṄi» Try it online! A full program that reads its input from STDIN and outputs to STDOUT. If the input validation and requirement to use STDIN were removed, this would be a single byte: Ṣ


2

C++ (clang), 223 \$\cdots\$ 190 182 bytes #import<regex> #import<iostream> int main(){std::string s,i="Invalid input";getline(std::cin,s);sort(begin(s),end(s));for(int c:s)s=c<48|c>122|c>57&c<97?i:s;s=s[0]?s:i;std::cout<<s;} Try it online! Saved 8 bytes thanks to ceilingcat!!! A program that reads a single string from ...


5

05AB1E, 16 15 bytes -1 byte thanks to Kevin Cruijssen žKlsSåßi{ë”Í¼î® Try it online!


3

Red, 86 bytes func[s][a: charset[#"0"-#"9"#"a"-#"z"]either parse sort s[some a][s]["Invalid input"]] Try it online!


4

APL (Dyalog Extended), 37 bytesSBCS {0∊(≢⍵),⍵∊⎕D,⌊⎕A:'Invalid input'⋄∧⍵}⍞ Try it online! ⍞ prompt for text input from the console {…} apply the following anonymous lambda to that:  ⎕A the uppercase Alphabet  ⌊ Lowercase that  ⎕D, prepend the digits  ⍵∊ for each character of the argument, indicate if it is a member thereof  (…), prepend the following:...


3

Keg, 35 bytes ₳0a&᠀:(⑴|⑻-)⒃᠀⒃¬+[Invalid input|¿÷⑭ Nice to see Keg still "up to par" with Golfscript! No regrets about the bad pun


3

GolfScript, 37 bytes .$\58,48>123,97>+-!*"Invalid input"or Try it online! Explanation Whoa. Maybe I shouldn't have done this.. . # Make 2 copies of the input, $ # One is the sorted copy of the input, \58,48>123,97>+-! # Another is whether all of input ...


4

Python 3.8 (pre-release), 77 75 74 88 bytes import re print(*re.match('[0-9a-z]+$',i:=input())and sorted(i)or'Invalid input',sep='') Try it online!


Top 50 recent answers are included