def judgePoint24(self, nums): bad = '떢븻각걎냇갅갸꺚뵟숣욄뵴뵞뤼갈갌뤔떌옊메늄숭캸긶꺛옖갍뇐쩢곴듇걯궄옕왹눞솴걃끗긬땉궿가쌀낐걄숤뺴늘걘꽸숢걂갋갃쫐꼔솾쩡쇔솿끛뤜간븺쩬웨딴옠뤛갂뵪덠놤빐옋귒늂갰갖놥궾갆옌뼘묰거갎긷낤겼' return chr(int(''.join(map(str, sorted(nums)))) + 42921) not in bad
There are really only 495 possible inputs, of which 404 are solvable and 91 aren't. The above is the shortest encoding of those 91 that I could think of. One character for each case. The +42921 is for getting all characters from the same unicode range (from the "Hangul Syllables" range) so that it looks good. For extra style points I shuffled them, otherwise they'd look somewhat sorted.
I am just speechless after seeing this post, how did you even end up with such a solution. You have got to be seeing something extra in the questions that I am not able to see, please share your thought process.
@ashish.katiyar I helped preparing the problem for the contest. For that, I tested solutions on all inputs. That's where I realized there aren't that many. And the solutions took about two minutes for all inputs, I think that's where I thought about pre-computing. Partly because I wanted a fast solution to easily compare other solutions against.
And then I just had fun making it small. I like doing things differently and coming up with stuff people don't usually think of. In the end I was a bit inspired by people occasionally posting here in Chinese or so. At least that's why I used the string as my title, just a little joke.
@StefanPochmann Just FYI, your solution is not in Chinese. It`s Korean. lol
@Ivan_Ouyang Yeah I know. I had tried Chinese first, but the characters didn't look as homogeneous. So I tried Korean instead and that looked much better. I just hope it's complete gibberish and not something offensive. I don't know any Korean and Google Translate didn't help at all.
@StefanPochmann Sorry, I cannot tell. Maybe ask a Korean friend to help and check if it is offensive or not.
class Solution: def judgePoint24(self, nums): """ :type nums: List[int] :rtype: bool """ bad = '对撒剘劥圞剜劏哱掶桺泛揋掵従剟剣彫寣污悫壛梄甏咍哲汭剤堧点卋嬞勆叛汬泐塵栋劚嚮咃宠吖剗楗囧力桻攋壯劯嗏桹劙剢剚焧啫栕炸栫栖嚲彳剛撑烃洿宋汷彲剙揁妷埻撧汢吩壙劇剭埼吕剝汣敯憇勇剥咎囻匓' return chr(int(''.join(map(str, sorted(nums)))) + 19968) not in bad
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.