Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options not deleted user 63675

Python 3 is the latest version of the Python programming language and was formally released on December 3rd, 2008. Use this tag along with the main python tag to denote programs that are meant to be run on a Python 3 interpreter only. Do not mix this tag with the python-2.x tag.

2 votes

Print matrix diagonals method

Here's a generator in a generator: m = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]] def diags(mat): width, height = len(mat[0]), len(mat) def diag(sx, sy): for x, …
L3viathan's user avatar
  • 307
1 vote

Number of sub strings with same first and last character

You're creating a few lists where you don't need them. I don't know if this fixes the timeout problem, but here's my take: def countF(s): l=len(s) return sum(int(s[i]==s[j-1]) for i in range( …
L3viathan's user avatar
  • 307
1 vote

Number of sub strings with same first and last character

Since this is something totally different, I have another answer, which should be in \$O(N)\$. With standard lib, but all unoptimized at the moment and just proof of concept: from collections import …
L3viathan's user avatar
  • 307