17
Derry Kabcenell
Last seen 1 year ago
Member for 7 years, 6 months, 5 days
Difficulty Normal
I was a professional software developer for Xerox (Mesa) and Oracle (mostly C) for about twenty years, but after a number of years in management and executive positions, and then retirement, I'm strictly an amateur. I value simple, elegant and easy-to-read solutions to programming problems, with brevity also a strong consideration, and performance important when there is a reason to prioritize it.
Nice use of sentinel at the bottom of the stack. A very minor suggestion: You could replace the last two lines with
return len(res) == 1
More
Beautifully simple. I'm wondering how you came up with the n//10 approximation. Is it a binary expansion of 0.1?
More
Very nice use of sentinel at the bottom of the stack. You don't need parentheses around if conditions like you do in C, and the first if condition could be 'i in ["[", "{", "("]' to be a little neater.
More
I like your use of a queue to keep track of teleports to be tried, and "len(set(path))" to see if you've reached all nodes.
More
Simple and straightforward. Except you could replace the "elif len(sor) %2 == 0" with a simple "else"; there are no other choices but 1 and 0.
More
Python can explode the date arguments for you: Use "date(*d1)" instead of "date(d1[0], d1[1], d1[2]).
More
You can let Python do the work of exploding the dates, using "date(*date1)". Also, the result of (d2 - d1).days is an integer, so you can use abs instead of fabs.
More
Note that you can allow Python to explode the dates for you:
date1 = date(*date1)
More
One suggestion: You wouldn't have to do the string replacement of 33, 222, etc. if you start with larger factors and count down to smaller ones -- if you get to 4, for example, and have found all the factors, you never need to try 3 and 2. Also, I don't think you need to test any factors above 9 sin
More
Nice. My solution is similar, but I didn't think of using reduce to create the final result.
More
I'm voting for this solution because I like Cyrillic -- even though I can't read a word of it.
More
Looks good. One observation is that don't have to go through the whole range of possible factors if you start at 9 and go backwards. Once you find adequate factors in the upper end of the range, you don't need to check the lower end since any digits down there will only make the result number longer
More
I believe this will work. I have two suggestions:
1. There's a comment that says "Create new list with non-unique elements". I think this means that you shouldn't modify the original list by removing elements, though I'm not sure.
2. You don't need to make the second call to "data.count(element)". I
More
Simple and straightforward. A couple of notes: In line 4, there are some extra parentheses surrounding the index that you don't need; and it is not necessary (but perfectly permissible) to use 2.0, a float, in line 6; in Python 3 the division will be floating point regardless of the arguments.
More
Looks good. My only suggestion would be to use sorted(data) and a new local variable, rather than sorting "data" in place. The caller might be unhappy if he/she is not expecting the argument to be changed.
More
Looks good. You could shorten it a bit by just making the list of Fibonacci numbers a variable, say "fibonaccis", and replacing "isFibNumber(age)" by "age in fibonaccis".
More