Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Favorites infavorites:mine
infavorites:1234
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with Search options user 19547

Code-golf is a competition to solve a particular problem in the fewest bytes of source code. If you want to score by characters instead of bytes, please state this explicitly in the challenge. If source code length is not the primary scoring criterion, consider using another tag instead.

1
vote
C# 210 205 139 138 135 128 113 Bytes using System.Linq;int f(string s,int x=0,int y=0)=>s.GroupBy(c=>(x+=c%6%3-1)+s+(y-=c/3%6-2)).Sum(g=>g.Count()%2); Explanation //Have X and Y as default params …
answered Aug 16 '16 by Phaeze
1
vote
C#, 56 Bytes int f(int a,int b){var r=1;for(;a<b;a++)r*=a;return r;}
answered Jul 25 '16 by Phaeze
2
votes
C# 314 305 299 249 232 223 Bytes using System.Linq;string f(int d,int m,int y){Func<int,string>r=i=>string.Concat((""+i).PadLeft(2,'0').Reverse());Func<string,int,string>x=(j,k)=>int.Parse(j)>k?""+k: …
answered Jul 27 '16 by Phaeze
11
votes
C#, 168 144 141 120 Bytes using System.Linq;i=>y=>string.Join("\n",y?i.Split('\n').Reverse():i.Split('\n').Select(x=>string.Concat(x.Reverse()))); New version utilizes the obvious string.Join overl …
answered Jul 13 '16 by Phaeze
4
votes
C# 125 98 Bytes using System.Linq;s=>s.GroupBy(c=>c).Where(g=>g.Key!=' ').Select(g=>new string(g.Key,g.Count()))); Explanation //Using anonymous function to remove the need for a full signature / …
answered Aug 24 '16 by Phaeze
2
votes
C# 64 62 56 50 Bytes s=>1>s.Split("aeiouAEIOU".ToCharArray()).Length%2; We are already using linq, so Contains saves 2 bytes over IndexOf Using the method overload of Count saves 6 bytes Thanks to …
answered Sep 20 '16 by Phaeze
0
votes
C# 88 86 Bytes f(int n,int a=1,int b=1,int c=1)=>n>1?n--%2>0?f(n,b,a+b,c):f(n,a,b+c,b):a+","+b+","+c; Explanation f(int n,int a=1,int b=1,int c=1)=> //Using an expression bodied function to allow …
answered Dec 28 '16 by Phaeze
2
votes
C# (with Linq) 90 81 73 71 69 68 Bytes using System.Linq;n=>n.Aggregate((p,c)=>p<9|c==p|c==103-p?'\b':c)>9; Explanation: using System.Linq; //Obligatory import n=>n.Aggregate((p,c)=> …
answered Dec 21 '16 by Phaeze
3
votes
C# 166 143 bytes, using System.Linq;s=>string.Join("\n",(s+=string.Concat(s.Reverse())).Select(x=>s.Aggregate("",(c, y)=>c+"- |"[Math.Sign(x.CompareTo(y))+1]))); Explanation: using System.Linq; s …
answered May 27 '16 by Phaeze
5
votes
C# 116 104 Bytes using System.Linq;(v,i)=>string.Join(".",v.Split('.').Select(int.Parse).Select((x,n)=>n==i?x+1:n>i?0:x)); Explanation using System.Linq;(v,i)=> //Anonymous function and mandator …
answered Dec 8 '16 by Phaeze
1
vote
C# with Linq, 51 Bytes using System.Linq;(n)=>(int)new[]{n,0,0}.Average(); Unfortunately much longer than the Mathematica version of this approach (pesky using statement), but pretty good for C#. …
answered Feb 8 '17 by Phaeze
2
votes
C# 110 109 107 103 101 94 Bytes using i=System.Numerics.BigInteger;i f(i n){i a=0,b=1,x=1;for(;n-->0;)x*=a=(b+=a)-a;return x;} Explanation //Aliasing BigInteger saves a few bytes using i=System.Nu …
answered Aug 11 '16 by Phaeze
8
votes
C#, 27 13 12 Bytes a=>b=>a%b<1; Thanks to TuukkaX for pointing out anonymous lambdas are acceptable. Thanks to David Conrad for pointing me on to currying which I wasn't even aware was a thing. Sh …
answered Jul 21 '16 by Phaeze