Skip to main content
Commonmark migration
Source Link

#C#6, 112 bytes#

C#6, 112 bytes

string c(string h,string n)=>h==""?"":h[0]==n[0]?h[0]+c(h.Substring(1),n.Substring(1)):"#"+c(h.Substring(1),n);

Recursive function, takes haystack h (input1) and needles n (input2).

  • If Haystack is empty, return it.
  • if first characters of haystack and needle are equal, keep the first character and call recursively while skipping the first char on both parameters
  • else return the replacement character (fixed to # here) followed by a recursive call again skipping the first character from haystack only.

Major factor for the length is the long name of Substring, but it's not long enough (compared to the number of usages) that a wrapping function would help to reduce further.

#C#6, 112 bytes#

string c(string h,string n)=>h==""?"":h[0]==n[0]?h[0]+c(h.Substring(1),n.Substring(1)):"#"+c(h.Substring(1),n);

Recursive function, takes haystack h (input1) and needles n (input2).

  • If Haystack is empty, return it.
  • if first characters of haystack and needle are equal, keep the first character and call recursively while skipping the first char on both parameters
  • else return the replacement character (fixed to # here) followed by a recursive call again skipping the first character from haystack only.

Major factor for the length is the long name of Substring, but it's not long enough (compared to the number of usages) that a wrapping function would help to reduce further.

C#6, 112 bytes

string c(string h,string n)=>h==""?"":h[0]==n[0]?h[0]+c(h.Substring(1),n.Substring(1)):"#"+c(h.Substring(1),n);

Recursive function, takes haystack h (input1) and needles n (input2).

  • If Haystack is empty, return it.
  • if first characters of haystack and needle are equal, keep the first character and call recursively while skipping the first char on both parameters
  • else return the replacement character (fixed to # here) followed by a recursive call again skipping the first character from haystack only.

Major factor for the length is the long name of Substring, but it's not long enough (compared to the number of usages) that a wrapping function would help to reduce further.

syntax highlighting
Source Link

#C#6, 112 bytes# string c(string h,string n)=>h==""?"":h[0]==n[0]?h[0]+c(h.Substring(1),n.Substring(1)):"#"+c(h.Substring(1),n);

string c(string h,string n)=>h==""?"":h[0]==n[0]?h[0]+c(h.Substring(1),n.Substring(1)):"#"+c(h.Substring(1),n);

Recursive function, takes haystack h (input1) and needles n (input2).

  • If Haystack is empty, return it.
  • if first characters of haystack and needle are equal, keep the first character and call recursively while skipping the first char on both parameters
  • else return the replacement character (fixed to # here) followed by a recursive call again skipping the first character from haystack only.

Major factor for the length is the long name of Substring, but it's not long enough (compared to the number of usages) that a wrapping function would help to reduce further.

#C#6, 112 bytes# string c(string h,string n)=>h==""?"":h[0]==n[0]?h[0]+c(h.Substring(1),n.Substring(1)):"#"+c(h.Substring(1),n);

Recursive function, takes haystack h (input1) and needles n (input2).

  • If Haystack is empty, return it.
  • if first characters of haystack and needle are equal, keep the first character and call recursively while skipping the first char on both parameters
  • else return the replacement character (fixed to # here) followed by a recursive call again skipping the first character from haystack only.

Major factor for the length is the long name of Substring, but it's not long enough (compared to the number of usages) that a wrapping function would help to reduce further.

#C#6, 112 bytes#

string c(string h,string n)=>h==""?"":h[0]==n[0]?h[0]+c(h.Substring(1),n.Substring(1)):"#"+c(h.Substring(1),n);

Recursive function, takes haystack h (input1) and needles n (input2).

  • If Haystack is empty, return it.
  • if first characters of haystack and needle are equal, keep the first character and call recursively while skipping the first char on both parameters
  • else return the replacement character (fixed to # here) followed by a recursive call again skipping the first character from haystack only.

Major factor for the length is the long name of Substring, but it's not long enough (compared to the number of usages) that a wrapping function would help to reduce further.

Source Link

#C#6, 112 bytes# string c(string h,string n)=>h==""?"":h[0]==n[0]?h[0]+c(h.Substring(1),n.Substring(1)):"#"+c(h.Substring(1),n);

Recursive function, takes haystack h (input1) and needles n (input2).

  • If Haystack is empty, return it.
  • if first characters of haystack and needle are equal, keep the first character and call recursively while skipping the first char on both parameters
  • else return the replacement character (fixed to # here) followed by a recursive call again skipping the first character from haystack only.

Major factor for the length is the long name of Substring, but it's not long enough (compared to the number of usages) that a wrapping function would help to reduce further.