Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
I made a slight improvement: since sudoku isn't about numbers, but it's about subsets, it's not necessary to convert the chars to integers (they are still numbers tho!). In addition, parsing the whole scheme in a 2D array is an extra passage, and in backtracking requires two indexes instead of one. Converting the 'i' index of the string to column and rows, and backwards, is done with easy calculations.
I didn't think about the ease of insertion. It is indeed more simple using a string
i decided to use a string because there is an existing code golf contest that includes a list of about 58000 sudoku puzzles formatted that way. And it's easier for a user to input a string than a 2d vector.
I redid it in c++, that's way easier because I don't run into timeouts.
Damn! you and I followed exactly the same way. i have wrote the exact same for loop and thus excution time ran out but after someday I wrote the following code and it worked.
You can do it better:
def prod(arr):
if arr:
return max(accumulate(arr, mul))
return 1
I first made it to work with 2d int arrays, but decided that for testing it's easier to work with strings.
yh xD
oh. apparently they added it to 3.8. you're right.
There is a math.prod()
This seems like a nice 8 kyu kata, maybe higher if the numbers get bigger because multiplying ints gets weird quickly.
If you look at the test cases, it's way easier than in my original kumite:
test.assert_equals(calculate_2048(s), (2**(ss+1),2**(ss+2)-4)) #don't tell the actual solver it's this easy
I just thought my way was more fun.
Cool!
Nice!
Didn't think of that.
for extra points, figure out how to do it using stacks instead of recursion
Loading more items...