# Tag Info

0

J, 21 bytes 0{[:(>\:#&>)/:~&></.] Try it online! Similar approach to Grimmy's answer.

1

Python 2, 79 bytes lambda A,S=sorted:A and S([[y for y in A if S(x)==S(y)]for x in A],key=len)[-1] Try it online! The A and... is only required to deal with the empty input.

0

Perl 6, 36 bytes {max .classify(~*.comb.sort){*}||''} Try it online! Output an empty string for an empty input. If we could output something else, for example -Inf, then this could be: Perl 6, 31 bytes *.classify(~*.comb.sort){*}.max Try it online!

0

Python 3, 14 bytes print(input()) Try it online! Basic.

1

Japt -h, 6 5 bytes üñ ñl Try it üñ ñl :Implicit input of array ü :Sort & group by ñ : Sorted strings ñ :Sort by l : Length :Implicit output of last element

0

Stax, 27 bytes éeO├φ☻mRàzΦ╛φ#2àáÿ²øΔ=L←§b Run and debug it Unpacked and Uncompressed A2#F~;3%z"Fizz"?;5%z"Buzz"?+cz=,a?P

0

Reflections, 61 53 bytes \ v0):v+\ */;++ ^;/ 0 >~\ |:^+| #@_ \ ^ 0\ \ */ Test it in the browser! Can handle infinite input (check the "Interactive" box), but not null bytes. As Reflections takes linewise input, but doesn't preserve the newlines, getting those right was the first problem. Basically, a newline is printed before every line but the ...

0

Forth (gforth), 46 bytes : f 0 do dup dup 1 type i 2 mod type 1+ loop ; Try it online! Code Explanation : f \ start a new word definition 0 do \ loop from 0 to string-len - 1 dup dup \ duplicate the current character address twice 1 type \ output the current letter i 2 mod type \ if odd, output again, if ...

0

W d, 22 bytes Seems like nobody ties with Dennis (Jelly has a "magical hook" that makes the a operand unneccecary). ☺▲¢Çfæ~z}µw■K8"╫↔#∩∞@Σ Uncompressed: 2^?SY%?a3m!*?SZ%?a5m!*+a|E Explanation 2^ E % Foreach in the 1..100 range a3m! % If the current item is divisible by 3: ?SY%? * % Return "...

2

05AB1E, 6 bytes .¡{}éθ Try it online! .¡ } # group the input strings by: { # sort (all permutations of each other will be identical when sorted) é # sort the groups by length θ # output the last (longest) group

1

Z80Golf, 28 bytes 00000000: 1680 cd03 8030 0578 ff79 ff76 fe5f 28f0 .....0.x.y.v._(. 00000010: 1930 ed0c fe7e 28e8 0d04 18e4 .0...~(..... Try it online! start: ld d, $80 call$8003 jr nc, ok results: ld a, b rst $38 ld a, c rst$38 halt ok: cp '_' jr z, start add hl, de jr nc, start inc c cp '~' jr z, start dec ...

0

Z80Golf, 12 bytes 00000000: d52e 76e5 2e07 e5cd 0380 38f6 ..v.......8. Try it online! push de Z:ld l, $76 push hl ld l, G push hl G:call$8003 jr c, Z+1 ; halt on EOF, else fallthrough Explanation Z80golf is a small Z80 computer hooked up to $8000=putchar,$8003=getchar. (putchar prints byte A; getchar reads a byte into A or sets ...

0

CJam, 9 bytes q3f*s1>2% Try it online! Explanation abcde q read input → aaabbbcccdddeee 3f*s repeat characters x3 → aabbbcccdddeee 1> drop first → a b b c d d e 2% every other char

0

Keg, 14 bytes :⑴½ℤ:a⅍*$b⅍*+= Try it online! Same approach as the stax answer. 3 Japt, 60 bytes i# {V}, {W} ßs {XmiSp4 R} YŒ ¯n [try Š Ò‚][o]! [o]: Try it 2 C (gcc), 162 bytes t(n,b,c,l)char*n,*c,*l;{for(printf("# %s, %d bytes\n\n ",n,b);*c;)putchar(*c++)-10?:printf(" ");printf("\n\nYou can [try it online][tio]!\n\n[tio]: %s",l);} There may be spaces after a trailing newline but I'm not sure if I'll be able to find a solution (or if a solution is even needed). You can try it online! 3 Kotlin, 83 109 101 95 bytes {n,b,c,l->"""#$n, $b bytes${c.prependIndent()} You can [try it online][tio]! [tio]: $l"""} Try it online! -6 bytes thanks to @snail_ -2 bytes thanks to @ovs -6 bytes since prependIndent has a default of 4 spaces 2 Jinja2, 102 bytes # {{n}}, {{b}} bytes {%for a in c%} {{a}} {%endfor%} You can [try it online][tio]! [tio]: {{l}} Does this count as a language? Used jinja cli from here: https://pypi.org/project/jinja2-cli/ I think it should as this is the usage to run it: jinja2 tio.j2 test.json --format=json It accepts a file as a program, and input in some ... 4 Haskell, 125 121 119 113 bytes -4 bytes thanks to kronicmage -2 bytes thanks to xnor (l!b)c t="# "++l++", "++show b++" bytes\n"++(("\n "++)=<<c)++"\n\nYou can [try it online][tio]!\n\n[tio]: "++t Try it online! 1 T-SQL, 134 bytes This can handle input lines of unequal length Using 0-based indexing SELECT n,max(z)FROM(SELECT substring(x,number+1,1)z,abs(number)n,*FROM spt_values,@)t GROUP BY n HAVING max(z)=min(z)and n<max(len(x)) Try it online 5 Red, 102 94 bytes -6 bytes thanks to Kevin Cruijssen! func[l n c u][reduce["#"rejoin[l","]n{bytes }c{ You can [try it online][tio]! [tio]:}u]] Try it online! 3 Python 3, 97 $\cdots$ 118 116 bytes Added 28 bytes to fix a bug kindly pointed out by RGS. Saved 2 bytes thanks to ovs!!! lambda n,b,c,l,x='\n':f"""# {n}, {b} bytes {c.replace(x,x+' '*4)} You can [try it online][tio]! [tio]: {l}""" Try it online! Takes code length as a parameter to save 3 bytes. 1 05AB1E (legacy), score: $9\frac{1}{4}$ (10 bytes - $\frac{3}{4}$ for both bonuses) |ø€Ùā‚øʒнg Outputs with 1-based indexing. Try it online. Uses the legacy version, because ø worked with a list of strings whereas the new version would need an explicit €S to convert each inner string to a list of characters first. It does mean I can't use the builtin .... 1 Charcoal, 67 56 bytes Ｆ⪪“⊟«Ｍ["Þ…εＵ↑⁵ï²¹@↧≡⊗»⭆∧⌕´r⪪ιυＮτ⁰⬤N➙⁺⁰UＹ⟧MyoJb⎇»﹪”¶«ι Ｓ You can try it online! Try it online! Link is to verbose version of code. Assumes you're not worried about Charcoal's default output padding, which can be turned off at a cost of 2 bytes. Explanation: Each input has a certain amount of text that appears before it, which always ... 2 Keg, -pn, 92 83 79 75 bytes ®N®l®b# ©N, ©b ¬E;s\n,÷(\$+,) ,“0:0X“ [try it a.;][tio]!\n[tio]: ©l+, Input is: Name, link, byte count and code Explained ®N®l®b We first take the inputs name, link and byte count and store them in variable N, l and b respectively. # ©N, ©b ¬E;s\n, Next, we construct a string that represents the header. The ©N ...

3

JavaScript (ES6), 102 bytes (n,b,c,l)=># ${n},${b} bytes ${c.replace(/^/gm, ' ')} You can [try it online][tio]! [tio]: `+l Try it online! "/^/gm" is a Global Multi-line replace of start line (^) 2 Japt, 85 bytes "# {U}, {V} bytes {" "+Wq" " q" "} You can [try it online][tio]! [tio]: "+X Try it online! 2 Wren, 117 bytes Just a normal string interpolation here. Fn.new{|a,b,c,d|"# %(a), %(b) bytes %(" "+c.split(" ").join(" ")) You can [try it online][tio]! [tio]: "+d} Try it online! 1 Burlesque, 16 bytes ln)XXtpzif{[~sm} Try it online! ln # Split to lines )XX # Split each line to chars tp # Transpose zi # Zip with indices f{ # Filter for [~ # Tail (i.e. chars) sm # All the same } 2 Java 10, 141 bytes (n,b,c,l)->{var t="";for(var p:c)t+=" "+p+"\n";return t.format("# %s, %d bytes\n\n%s\nYou can [try it online][tio]!\n\n[tio]: "+l,n,b,t);} Takes the byte-count as integer-input, and the code as an array of String-lines. Try it online. Explanation: (n,b,c,l)->{ // Method with four parameters and String return-type var t=""... 4 PHP, 134 132 125 119 bytes # <?=($a=$argv).",$a bytes ".preg_replace("/^/m"," ",$a)." You can [try it online][tio]! [tio]:$a"; Try it online! Finally an easy job for PHP! EDIT: easily saved 2 bytes with concatenation in first <?= EDIT 2: saved another 7 bytes, just remembered that multi-lines strings work in PHP with " EDIT 3: ...

6

05AB1E (legacy), 56 53 52 51 50 bytes “# ÿ, ÿ¡Ï“I4ú»"[tio]"D“You€© [try€•€Ø]ÿ!“s¶·ý„: IJ Inputs in the order name, byte-count, [code-lines], link, where the [code-lines] is a list of lines. Try it online. 50 bytes alternative (credit to @Grimmy): “:# ÿ, ÿ¡Ï“I4ú»“You€© [try€•€Ø][tio]!“Â6£R¨¶·ýÀ$ú« Try it online. Explanation: “# ÿ, ÿ¡Ï“ # Push ... 2 W j, 77 bytes # "a", "ck" bytes "c' ," ":@\+" You can [try it online][tio]! [tio]: "b Explanation % Header section # " % The beginning header a % The first input (the language name) ", " % The comma & space ck % The length of the program (taken at the 3rd input) " bytes % ... 7 Ruby, 98 95 bytes Really simple string interpolation. I don't think there's all that much to optimize here that will save a lot of bytes. Takes the byte count as a parameter in order to save 3 bytes, as per Kevin Cruijssen's suggestion. ->n,b,c,l{"# #{n}, #{b} bytes #{c.gsub /^/,' '} You can [try it online][tio]! [tio]: "+l} Try it online! 0 CJam, 12 bytes q2/{_La+1=}% Try it online! Explanation q2/{_La+1=}% q2/ Read the input and split it into groups of 2 characters. { }% For each group: _ Copy it. La+ Append an empty string. 1= Get its second element. Join the results. -1 Python 3, 96 bytes y=list(x) for i in x: n = y.index(i) if n%2!=0: y[n]=y[n]*2 for i in y: d+=i Try it online! Takes x as input, prints d as output. New to codegolf, so very basic. 0 Haskell, 75 bytes x n|elem n[x|x<-['B'..'z'],notElem x"EIOUaeiou"]=[n,'o',n]|1<2=[n] f=(>>=x) This is a slight improvement on nimi's answer (unfortunately I can't comment yet) which uses a "clever" way to generate a list of consonants ([x|x<-['B'..'z'],notElem x"EIOUaeiou"]) that saves 6 bytes over just listing them out. In this case ['B'..'... 0 Japt v2.0a0, 7 bytes r\c_+io Try it 2 Python 3.8 (pre-release), 142 bytes s=input() g=lambda i,f='aeiuoy':i if s[i]in f else g(i+1,f) q=g(g(0),c:='pgtcvkh jglmn bqrzd fwx s') exit(s[:-~q]+(c[ord(s[q])-98]+s[g(q)])*2) Try it online! A little late to the party, but here's yet another non-regex Python answer! I interpreted the rules to allow printing to STDERR which saves a byte (exit/print). ... 0 Unix TMG, 83 bytes Another compiler-compiler solution (in addition to Yacc). p:s parse((any(!<<>>)|={<1>}));s:b s/d;d:;b:<[>x<]>|<{>x<}>|<(>x<)>|<<>x<>>;x:s|(); Unlike Yacc, it works by recursive-descent parsing. It outputs "1" on success, nothing – otherwise. Expanded: p: s parse((... 2 05AB1E, 16 15 13 bytes -2 bytes thanks to Kevin Cruijssen žNDu«SD'o«€Ć‡ Try it online! 2 PHP, 75% foreach(count_chars($argn)as$c)$o[]=$c*'1111111111111111111111111111111111111111001111111111111111111111111111111111111111111111111010111111111111111111111111111110101111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111'[$i++];arsort($o);echo chr(key($o)); Try it online! ...

5

05AB1E, 99.999999999999999957% 1111111111111111111 ... (9352835025086960662 1's total) ... 11111g₅B.V g gets the length of the large integer literal. Obviously this is too long for TIO, so try a version using 9352835025086960662 instead of the equivalent 1111...1111g.

1

05AB1E, tends to 50% '""{}[]()"'""м.M"J".V"".V"".V".V Try it online! You can keep appending ".V" before the final J, any part of this string can't be removed and hence none of the characters themselves are non-trivial. Hence this tends to 50% of the program being " as you add more ".V" Note: you couldn't have a single char command to tend to 66% inside ...

0

C (gcc), 13.2% ; float m;a;l;t;c;n(char*s){bzero(a,1024);l=0;for(;*s;){a[*s]++;s++;l++;};m=0;t=0;for(;t++<255;)if(a[t]>m)c=t,m=a[t];m*=100;printf("%c %f\n",c,m/l);} This version doesn't pad the end with semicolons. It only contains a few unneeded ones to push up my score to the next percent. Feel free to add semicolons up until you get 100%. ...

2

JavaScript (Node.js), 55.85% (or much more) s=>eval(Buffer((g=n=>n?[+[n&127n],...g(n>>7n)]:[])(...

3

JavaScript (ES6) Port of G B's Ruby answer. a=>a.filter(v=>v!='_').map((v,i)=>i%2||v=='P'?0:a[+(v=='o')]++,a=[0,0])&&a

0

PHP, 398 bytes function e($z,$x,$y=null){$y=is_null($y)?$x:$y;for($i=0,$o=preg_split('/([^A-Za-z0-9 ])/',$z,0,2);$i<count($o);$o[$i]=$s,$i+=2)for($s=substr(($s=$o[$i]).$s.$s,($l=strlen($s))-$x,$l),$j=0;$j<strlen($s);$j++)if(($c=$s[$j])!=' ')$s[$j]=(chr(ctype_digit($c)?(ord($c)+$y-38)%10+48:(ord($c)+$y-($p=ctype_lower($c)?97:65)+26)%26+\$p));return join(...

1

C++ (gcc), 189 184 170 bytes #include <string> struct a{int t;int f;};a f(std::string s){a r={0,0};for(int i=0,d=1;i<s.length();++i)s[i]%3?s[i]%2?1:d=0:s[i++]%2?d?r.f++:r.t++:d?r.t++:r.f++;return r;} Try it online! Expanded Version (Full Program) : // Example program #include <iostream> #include <string.h> using namespace std; ...

0

First version, a bit verbose yet, I'll try to optimize: "fully cyclic caesar" (9+1 becomes 0, z+1 becomes a, Z+1 becomes A) breaks on anything not a space or char (a-z A-Z 0-1) (I think your last example is wrong, it breaks on the last ', which is intended) default values if missing: 1 / 1 (same value for both, could be up to 9 without extra byte) ...

Top 50 recent answers are included