loading...

Discussion on: The easiest problem you cannot solve.

Collapse
entrptaher profile image
Md. Abu Taher 👨‍💻

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 Author

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 Author

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 Author

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

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

Very creative!

Collapse
joelnet profile image
JavaScript Joel Author

There is no restriction to call K, right?

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

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
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 Author

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