DEV Community

Discussion on: The easiest problem you cannot solve.

Collapse
 
entrptaher profile image
Md Abu Taher • Edited

There is no restriction to call K, right?

K(K)(cat)(dog)()
K(dog)()

Done! Both of these should output dog.

Update: You can actually put anything you want instead of cat. Or complicate it even more with infinite recursive inputs.

K(K)()(dog)()
K(K(K)()(dog))(K)()
K(K(K)(cat)(dog))()()
Collapse
 
joelnet profile image
JavaScript Joel

Minions clapping and screaming

I assumed the other solution would have been found first.

Congratulations!

Collapse
 
entrptaher profile image
Md Abu Taher

Well I updated with other solution.

Thread Thread
 
joelnet profile image
JavaScript Joel

haha I didn't consider K(dog)() would be within the rules. I have updated to rules to require both dog and cat to appear exactly once ;)

Thread Thread
 
entrptaher profile image
Md Abu Taher

Lol no! You cannot change the rules after I won :P

Thread Thread
 
joelnet profile image
JavaScript Joel

I'm still giving you credit for both solutions ;)

Collapse
 
joelnet profile image
JavaScript Joel
K(K)()(dog)()
K(K(K)()(dog))(K)()
K(K(K)(cat)(dog))()()

Very creative!

Collapse
 
theodesp profile image
Theofanis Despoudis

"cat and dog must appear exactly once."

That violates

K(dog)()
K(K)()(dog)()
K(K(K)()(dog))(K)()

Collapse
 
joelnet profile image
JavaScript Joel

I added that rule in afterwards. These solutions were valid at the time he posted, so I'll give him credit for the creativity :)

Collapse
 
entrptaher profile image
Md Abu Taher

I was the first to solve his problem :D
He changed the rules after I posted my solution.
Check the comments.

Collapse
 
joelnet profile image
JavaScript Joel

There is no restriction to call K, right?

There is also a solution with a single call to K :)