Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

added 275 characters in body
Source Link
emanresu A
  • 46.2k
  • 5
  • 111
  • 257

Regex (any)

^([^e]*|[^to]*|[^for]*|[^si]*)$

Just using @xash's trick again. Takes a single string.

Javascript, 44 bytes (using regex)

x=>/^([^e]*|[^to]*|[^for]*|[^si]*)$/.test(x)

I mean it works, but I like the other one because it took more than 2 minutes. Takes a single string.

Regex (any)

^([^e]*|[^to]*|[^for]*|[^si]*)$

Just using @xash's trick again. Takes a single string.

Javascript, 44 bytes (using regex)

x=>/^([^e]*|[^to]*|[^for]*|[^si]*)$/.test(x)

I mean it works, but I like the other one because it took more than 2 minutes. Takes a single string.

deleted 47 characters in body
Source Link
emanresu A
  • 46.2k
  • 5
  • 111
  • 257

JavaScript (Node.js), (削除) 99 (削除ここまで) 95(削除) 95 (削除ここまで) 78 bytes

x=>y=>!'e to for si'.split` `.filter(m=>!m[.split``.map.m].some(k=>(x+y).includes(k)).includes(true))[0]

Try it online!

Uses xash's idea from his J answer.

Returns false for yes and true for no (counterintuitive I know, deal with it). Uses currying syntax - (x)(y).

Explanation:

x=> //declare function
 y=> //declare function 2
 ! // necessary for consistent result
 'e to for si' //see xash's J answer
 .split` ` // to array
 .filter( //keep value only if following true
 m=> //function with value m
 ! //if following is false
 m[.split``..m]  //m into array of letters
 .mapsome( //replace each with
 k=> //function of k
 (x+y).includes(k) //Mapif toincludes twotrue words(input togethercontains includingone kof word
 ).includes(true) //if includes true (input contains one of word
 ) // array now has any items only if it contains something
 [0] //0th item, undefined if no answers, one of strings above if does, then negated by ! at top.

There's got to be a better way to do all the .includes.

JavaScript (Node.js), (削除) 99 (削除ここまで) 95 bytes

x=>y=>!'e to for si'.split` `.filter(m=>!m.split``.map(k=>(x+y).includes(k)).includes(true))[0]

Try it online!

Uses xash's idea from his J answer.

Returns false for yes and true for no (counterintuitive I know, deal with it). Uses currying syntax - (x)(y).

Explanation:

x=> //declare function
 y=> //declare function 2
 ! // necessary for consistent result
 'e to for si' //see xash's J answer
 .split` ` // to array
 .filter( //keep value only if following true
 m=> //function with value m
 ! //if following is false
 m.split`` //m into array of letters
 .map( //replace each with
 k=> //function of k
 (x+y).includes(k) //Map to two words together including k
 ).includes(true) //if includes true (input contains one of word
 ) // array now has any items only if it contains something
 [0] //0th item, undefined if no answers, one of strings above if does, then negated by ! at top.

There's got to be a better way to do all the .includes.

JavaScript (Node.js), (削除) 99 (削除ここまで) (削除) 95 (削除ここまで) 78 bytes

x=>y=>!'e to for si'.split` `.filter(m=>![...m].some(k=>(x+y).includes(k)))[0]

Try it online!

Uses xash's idea from his J answer.

Returns false for yes and true for no (counterintuitive I know, deal with it). Uses currying syntax - (x)(y).

Explanation:

x=> //declare function
 y=> //declare function 2
 ! // necessary for consistent result
 'e to for si' //see xash's J answer
 .split` ` // to array
 .filter( //keep value only if following true
 m=> //function with value m
 ! //if following is false
 [...m]  //m into array of letters
 .some( //replace each with
 k=> //function of k
 (x+y).includes(k) //if includes true (input contains one of word
 ) 
 ) // array now has any items only if it contains something
 [0] //0th item, undefined if no answers, one of strings above if does, then negated by ! at top.

There's got to be a better way to do all the .includes.

Added explanantion, improved answer
Source Link
emanresu A
  • 46.2k
  • 5
  • 111
  • 257

JavaScript (Node.js), 99(削除) 99 (削除ここまで) 95 bytes

x=>y=>!'e to for si'.split` `.filter(m=>!m.split``.map(k=>(x+y).includes(k)).includes(true)).length[0]

Try it online! Try it online!

Uses xash's idea from his J answer.

Returns false for yes and true for no (counterintuitive I know, deal with it). Uses currying syntax - (x)(y).

Explanation:

x=> //declare function
 y=> //declare function 2
 ! // necessary for consistent result
 'e to for si' //see xash's J answer
 .split` ` // to array
 .filter( //keep value only if following true
 m=> //function with value m
 ! //if following is false
 m.split`` //m into array of letters
 .map( //replace each with
 k=> //function of k
 (x+y).includes(k) //Map to two words together including k
 ).includes(true) //if includes true (input contains one of word
 ) // array now has any items only if it contains something
 [0] //0th item, undefined if no answers, one of strings above if does, then negated by ! at top.

There's got to be a better way to do all the .includes.

JavaScript (Node.js), 99 bytes

x=>y=>!'e to for si'.split` `.filter(m=>!m.split``.map(k=>(x+y).includes(k)).includes(true)).length

Try it online!

Uses xash's idea from his J answer.

Returns false for yes and true for no (counterintuitive I know, deal with it). Uses currying syntax - (x)(y).

JavaScript (Node.js), (削除) 99 (削除ここまで) 95 bytes

x=>y=>!'e to for si'.split` `.filter(m=>!m.split``.map(k=>(x+y).includes(k)).includes(true))[0]

Try it online!

Uses xash's idea from his J answer.

Returns false for yes and true for no (counterintuitive I know, deal with it). Uses currying syntax - (x)(y).

Explanation:

x=> //declare function
 y=> //declare function 2
 ! // necessary for consistent result
 'e to for si' //see xash's J answer
 .split` ` // to array
 .filter( //keep value only if following true
 m=> //function with value m
 ! //if following is false
 m.split`` //m into array of letters
 .map( //replace each with
 k=> //function of k
 (x+y).includes(k) //Map to two words together including k
 ).includes(true) //if includes true (input contains one of word
 ) // array now has any items only if it contains something
 [0] //0th item, undefined if no answers, one of strings above if does, then negated by ! at top.

There's got to be a better way to do all the .includes.

Source Link
emanresu A
  • 46.2k
  • 5
  • 111
  • 257
Loading

AltStyle によって変換されたページ (->オリジナル) /