## CJam, 24 bytes qS/Wf%[_1=:=31^sCs].e<S* I/O format is `dd mm yyyy`. [Try it online!][1] Same byte count, I/O format `mm dd yyyy`: qS/Wf%_0=:=1231^s2/.e<S* [Try it online!][2] ### Explanation qS/ e# Read input, split around spaces. Wf% e# Reverse each component. [ e# Set marker for new list. _1= e# Duplicate reversed strings, extract reversed month. := e# Check for equality for the characters. This gives 1 for e# November (11) and 0 for everything else. 31^ e# XOR the result with 31, giving 30 for November and 31 e# for everything else. s e# Convert the result to a string, "30"/"31". Cs e# Push 12, convert to string, "12". ] e# Wrap "30"/"31" and "12" in a list. .e< e# Element-wise minimum. This clamps the day and month to their e# respective maxima. S* e# Join the result with spaces. The other version works similarly, except that we start from the integer `1230` or `1231` before converting it to `["12" "30"]` or `["12" "31"]`. [1]: http://cjam.tryitonline.net/#code=cU4vezpROwoKUVMvV2YlW18xPTo9MzFec0NzXS5lPFMqCgpdbn0v&input=MjEgMDcgMjAxNgoxMiAxMSAxOTkxCjAxIDAxIDIwMDAKMjcgMDggMTg3NQoxOCAxMiAyMDEwCjEzIDAxIDE5ODEKMDQgMTEgMTY3MQoyOCAxMSAyMDM2CjE0IDA2IDE4NTUKMzAgMTAgOTk5OQowMSAwMSAyODUx [2]: http://cjam.tryitonline.net/#code=cU4vezpROwoKUVMvV2YlXzA9Oj0xMjMxXnMyLy5lPFMqCgpdbn0v&input=MDcgMjEgMjAxNgoxMSAxMiAxOTkxCjAxIDAxIDIwMDAKMDggMjcgMTg3NQoxMiAxOCAyMDEwCjAxIDEzIDE5ODEKMTEgMDQgMTY3MQoxMSAyOCAyMDM2CjA2IDE0IDE4NTUKMTAgMzAgOTk5OQowMSAwMSAyODUx