diff options
| author | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2024-01-29 04:49:37 +0000 |
|---|---|---|
| committer | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2024-01-29 04:49:37 +0000 |
| commit | 45892f35c3d5306dc9498cc404169a21486a2bf9 (patch) | |
| tree | 1a3ba13b56bc757428e4baaedda476d86d515bdb /challenge-253/luca-ferrari/python/ch-2.python | |
| parent | c13d4891bfaede87ed0689441bf47e15fe1e880e (diff) | |
| download | perlweeklychallenge-club-45892f35c3d5306dc9498cc404169a21486a2bf9.tar.gz perlweeklychallenge-club-45892f35c3d5306dc9498cc404169a21486a2bf9.tar.bz2 perlweeklychallenge-club-45892f35c3d5306dc9498cc404169a21486a2bf9.zip | |
- Added template for week 254.
Diffstat (limited to 'challenge-253/luca-ferrari/python/ch-2.python')
| -rw-r--r-- | challenge-253/luca-ferrari/python/ch-2.python | 49 |
1 files changed, 0 insertions, 49 deletions
diff --git a/challenge-253/luca-ferrari/python/ch-2.python b/challenge-253/luca-ferrari/python/ch-2.python deleted file mode 100644 index 2e4abff0e5..0000000000 --- a/challenge-253/luca-ferrari/python/ch-2.python +++ /dev/null @@ -1,49 +0,0 @@ -#!python - -# -# Perl Weekly Challenge 253 -# Task 2 -# -# See <https://perlweeklychallenge.org/blog/perl-weekly-challenge-253> -# - -import sys -import collections - -# task implementation -# the return value will be printed -def task_2( args ): - ones = {} - for row_index in range( 0, len( args ) ): - sum = 0 - for x in args[ row_index ]: - sum += x - - if not sum in ones: - ones[ str( sum ) ] = [] - - ones[ str( sum ) ].append( row_index ) - - keys = list( ones.keys() ) - keys.sort() - result = "" - for k in keys: - ones[ k ].sort() - for v in ones[ k ]: - result += str( v ) + ',' - - - return result - - - -# invoke the main without the command itself -if __name__ == '__main__': - matrix = [ - [1, 1, 0, 0, 0], - [1, 1, 1, 1, 0], - [1, 0, 0, 0, 0], - [1, 1, 0, 0, 0], - [1, 1, 1, 1, 1] - ] - print( task_2( matrix ) ) |
