22
→ Faibbus
Last seen 2 years ago
Member for 11 years, 4 months, 28 days
Difficulty Normal
Hello, naming things explicitely would help make your code clearer.
Also line 5 could be simplified as `subj = (x.lower() for x in subj if x.isalpha())`
More
You are only a few comments away from perfection...
But anyway, that's impressive.
More
The demonstration of the solution is a nice addition :)
More
Hello, since you are using `re.match`, you don't need to specify `^` in your regexes.
You could also have removed the _(debug)_ print statements.
But since you made an effort on the docstrings and variable names, here are some upvotes 😉
More
Your formula is correct, but it could be simplified:
```
t2 × adv adv × (a1 - t2) + t2 × adv adv × a1
adv + ------------ = ---------------------------- = ----------
a1 - t2 a1 - t2 a1 - t2
```
More
I find it not-so-great that all these lines of code are duplicated to just change a "<" to ">".
On the other hand, I like the idea of caching the keys.
More
Hello, your formula is correct, but it could be further simplified:
```
t2 × adv adv × (a1 - t2) + t2 × adv adv × a1
adv + ------------ = ---------------------------- = ----------
a1 - t2 a1 - t2 a1 - t2
```
More
Hello,
- nice use of `isupper` 😀
- `pat` could be simplified by using `search` instead of `match`
- `pat1` could be simplified as `'[^A-Za-z0-9 ]'`
- line 8 could be abbriged to `if pat.match(sub)`
- line 12 could be improved with `enumerate`: `for i, word in enumerate(c):` and then use `word` inst
More
I don't think this solution qualifies as Speedy.
You iterate:
- once on `array` (let's say its size is `n`);
- once on results (size `n//2`) to build `result1`;
- once again on `results1` (for the `sum`, size `n//2`).
So you could actually save `n` iterations (and some memory) with something al
More
Your formula is correct, but it could be simplified:
```
t2 × adv adv × (a1 - t2) + t2 × adv adv × a1
adv + ------------ = ---------------------------- = ----------
a1 - t2 a1 - t2 a1 - t2
```
More
I'm not sure about caching in python, but it might be best to sort your data only once.
More
Sometimes, 3 lines are better than one ;)
I came up with almost the same solution ^^ but yours' even shorter.
More
Hmm, using my crystal ball, I'd say that your solution might only work in 1/4th of the times...
More
checkio = lambda data:(lambda f:(data[0][0] if len(data)==1 else sum([data[0][k]*(-1)**k*checkio(f(data,0,k)) for k in range(len(data))])))(lambda d,i,j:([[d[l][c] for c in range(len(d)) if c != j] for l in range(len(d)) if l != i]))
Ok, I hadn't thought about that.
Using that, the code would
More