Skip to main content
added 108 characters in body
Source Link
Charlie
  • 13k
  • 2
  • 44
  • 100

C# (.NET Core), 48 47 46 bytes, input as char array

s=>{for(int i=0;s[++i]==++s[0];);return s[0];} 

Try it online!

Explanation: the first element in the array is incremented as well as a pointer iterating the following elements. When both the first element and the current element are different, it returns the first element.

C# (.NET Core), 58 56 50 bytes, input as string

s=>{var c=s[0];while(s.IndexOf(++c)>=0);return c;} 

Try it online!

Previous 58-byte solution (referenced in the first comment):

s=>{for(int i=1;;i++)if(s[i]-s[0]>i)return(char)(s[i]-1);} 

Algorithms using System.Linq

The following algorithmalgorithms must add using System.Linq; (18 bytes) to the byte count and therefore isare longer, but.

I quite liked itthis one (52+18 bytes):

s=>{int i=0;return(char)(s.First(c=>c-s[0]>i++)-1);} 

And you also have a one-liner (45+18)-byte solution:

s=>(char)(s.Where((c,i)=>c-s[0]>i).First()-1) 

And a very clever (37+18)-byte solution, courtesy of Ed'ka:

s=>s.Select(e=>++e).Except(s).First() 

C# (.NET Core), 48 47 46 bytes, input as char array

s=>{for(int i=0;s[++i]==++s[0];);return s[0];} 

Try it online!

Explanation: the first element in the array is incremented as well as a pointer iterating the following elements. When both the first element and the current element are different, it returns the first element.

C# (.NET Core), 58 56 50 bytes, input as string

s=>{var c=s[0];while(s.IndexOf(++c)>=0);return c;} 

Try it online!

Previous 58-byte solution (referenced in the first comment):

s=>{for(int i=1;;i++)if(s[i]-s[0]>i)return(char)(s[i]-1);} 

The following algorithm must add using System.Linq; to the byte count and therefore is longer, but I quite liked it (52+18 bytes):

s=>{int i=0;return(char)(s.First(c=>c-s[0]>i++)-1);} 

And you also have a one-liner (45+18)-byte solution:

s=>(char)(s.Where((c,i)=>c-s[0]>i).First()-1) 

C# (.NET Core), 48 47 46 bytes, input as char array

s=>{for(int i=0;s[++i]==++s[0];);return s[0];} 

Try it online!

Explanation: the first element in the array is incremented as well as a pointer iterating the following elements. When both the first element and the current element are different, it returns the first element.

C# (.NET Core), 58 56 50 bytes, input as string

s=>{var c=s[0];while(s.IndexOf(++c)>=0);return c;} 

Try it online!

Previous 58-byte solution (referenced in the first comment):

s=>{for(int i=1;;i++)if(s[i]-s[0]>i)return(char)(s[i]-1);} 

Algorithms using System.Linq

The following algorithms must add using System.Linq; (18 bytes) to the byte count and therefore are longer.

I quite liked this one (52+18 bytes):

s=>{int i=0;return(char)(s.First(c=>c-s[0]>i++)-1);} 

And you also have a one-liner (45+18)-byte solution:

s=>(char)(s.Where((c,i)=>c-s[0]>i).First()-1) 

And a very clever (37+18)-byte solution, courtesy of Ed'ka:

s=>s.Select(e=>++e).Except(s).First() 
added 214 characters in body
Source Link
Charlie
  • 13k
  • 2
  • 44
  • 100

C# (.NET Core), 48 47 46 bytes, input as char array

s=>{for(int i=0;s[++i]==++s[0];);return s[0];} 

Try it online!

Explanation: the first element in the array is incremented as well as a pointer iterating the following elements. When both the first element and the current element are different, it returns the first element.

C# (.NET Core), 58 56 50 bytes, input as string

s=>{var c=s[0];while(s.IndexOf(++c)>=0);return c;} 

Try it online!

Previous 58-byte solution (referenced in the first comment):

s=>{for(int i=1;;i++)if(s[i]-s[0]>i)return(char)(s[i]-1);} 

The following algorithm must add using System.Linq; to the byte count and therefore is longer, but I quite liked it (52+18 bytes):

s=>{int i=0;return(char)(s.First(c=>c-s[0]>i++)-1);} 

And you also have a one-liner (45+18)-byte solution:

s=>(char)(s.Where((c,i)=>c-s[0]>i).First()-1) 

C# (.NET Core), 48 47 46 bytes, input as char array

s=>{for(int i=0;s[++i]==++s[0];);return s[0];} 

Try it online!

C# (.NET Core), 58 56 50 bytes, input as string

s=>{var c=s[0];while(s.IndexOf(++c)>=0);return c;} 

Try it online!

Previous 58-byte solution:

s=>{for(int i=1;;i++)if(s[i]-s[0]>i)return(char)(s[i]-1);} 

The following algorithm must add using System.Linq; to the byte count and therefore is longer, but I quite liked it (52+18 bytes):

s=>{int i=0;return(char)(s.First(c=>c-s[0]>i++)-1);} 

And you also have a one-liner (45+18)-byte solution:

s=>(char)(s.Where((c,i)=>c-s[0]>i).First()-1) 

C# (.NET Core), 48 47 46 bytes, input as char array

s=>{for(int i=0;s[++i]==++s[0];);return s[0];} 

Try it online!

Explanation: the first element in the array is incremented as well as a pointer iterating the following elements. When both the first element and the current element are different, it returns the first element.

C# (.NET Core), 58 56 50 bytes, input as string

s=>{var c=s[0];while(s.IndexOf(++c)>=0);return c;} 

Try it online!

Previous 58-byte solution (referenced in the first comment):

s=>{for(int i=1;;i++)if(s[i]-s[0]>i)return(char)(s[i]-1);} 

The following algorithm must add using System.Linq; to the byte count and therefore is longer, but I quite liked it (52+18 bytes):

s=>{int i=0;return(char)(s.First(c=>c-s[0]>i++)-1);} 

And you also have a one-liner (45+18)-byte solution:

s=>(char)(s.Where((c,i)=>c-s[0]>i).First()-1) 
deleted 30 characters in body
Source Link
Charlie
  • 13k
  • 2
  • 44
  • 100

C# (.NET Core), 48 47 46 bytes, input as char array

(Takes input as a char array.)

s=>{for(int i=0;s[++i]==++s[0];);return s[0];} 

Try it online!

C# (.NET Core), 58 56 50 bytes, input as string

(Takes input as a string.)

s=>{var c=s[0];while(s.IndexOf(++c)>=0);return c;} 

Try it online!

Previous 58-byte solution:

s=>{for(int i=1;;i++)if(s[i]-s[0]>i)return(char)(s[i]-1);} 

The following algorithm must add using System.Linq; to the byte count and therefore is longer, but I quite liked it (52+18 bytes):

s=>{int i=0;return(char)(s.First(c=>c-s[0]>i++)-1);} 

And you also have a one-liner (45+18)-byte solution:

s=>(char)(s.Where((c,i)=>c-s[0]>i).First()-1) 

C# (.NET Core), 48 47 46 bytes

(Takes input as a char array.)

s=>{for(int i=0;s[++i]==++s[0];);return s[0];} 

Try it online!

C# (.NET Core), 58 56 50 bytes

(Takes input as a string.)

s=>{var c=s[0];while(s.IndexOf(++c)>=0);return c;} 

Try it online!

Previous 58-byte solution:

s=>{for(int i=1;;i++)if(s[i]-s[0]>i)return(char)(s[i]-1);} 

The following algorithm must add using System.Linq; to the byte count and therefore is longer, but I quite liked it (52+18 bytes):

s=>{int i=0;return(char)(s.First(c=>c-s[0]>i++)-1);} 

And you also have a one-liner (45+18)-byte solution:

s=>(char)(s.Where((c,i)=>c-s[0]>i).First()-1) 

C# (.NET Core), 48 47 46 bytes, input as char array

s=>{for(int i=0;s[++i]==++s[0];);return s[0];} 

Try it online!

C# (.NET Core), 58 56 50 bytes, input as string

s=>{var c=s[0];while(s.IndexOf(++c)>=0);return c;} 

Try it online!

Previous 58-byte solution:

s=>{for(int i=1;;i++)if(s[i]-s[0]>i)return(char)(s[i]-1);} 

The following algorithm must add using System.Linq; to the byte count and therefore is longer, but I quite liked it (52+18 bytes):

s=>{int i=0;return(char)(s.First(c=>c-s[0]>i++)-1);} 

And you also have a one-liner (45+18)-byte solution:

s=>(char)(s.Where((c,i)=>c-s[0]>i).First()-1) 
deleted 11 characters in body
Source Link
Charlie
  • 13k
  • 2
  • 44
  • 100
Loading
added 732 characters in body
Source Link
Charlie
  • 13k
  • 2
  • 44
  • 100
Loading
deleted 3 characters in body
Source Link
Charlie
  • 13k
  • 2
  • 44
  • 100
Loading
deleted 4 characters in body
Source Link
Charlie
  • 13k
  • 2
  • 44
  • 100
Loading
added 125 characters in body
Source Link
Charlie
  • 13k
  • 2
  • 44
  • 100
Loading
added 119 characters in body
Source Link
Charlie
  • 13k
  • 2
  • 44
  • 100
Loading
added 182 characters in body
Source Link
Charlie
  • 13k
  • 2
  • 44
  • 100
Loading
Source Link
Charlie
  • 13k
  • 2
  • 44
  • 100
Loading