Skip to content

SibDiP/Codewars_solutions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

85 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Codewars_solutions

My codewars solutions written on #python.

Main purpose: tracking progress and easy navigation through solved task examples

Codewars


Date Kata Theme
1 2022-11-19 5_kyu_Maximum_subarray_sum Kadane's Algorithm
2 2022-11-20 5_kyu_Moving_Zeros_To_The_End Algorithms
3 2022-11-21 5_kyu_Calculating_with_Functions 1. nonlocal, global var
2. oneliners, lambda
4 2022-11-24 8_kyu_Find_the_position! 1. oneliner, str.find(), f-string
2. ord(), askii
5 2022-11-25
2025-08-27
5_kyu_Human_Readable_Time 1. f-string oneliner
2. digit formatting {num:dd}
3. dict, direct calculations, f-string
4. divmod(), constant, list, for-loop, ":".join()
6 2022-12-01 5_kyu_Rot13 1. ord(), ascii
2. txt.translate(maketrans())
7 2022-12-03 5_kyu_Pete_the_baker 1. loop, try/except/min()
2. oneliner, get()
8 2022-12-15 8_kyu_Square(n)_Sum 1. for loop oneliner
9 2022-12-17 7_kyu_Square_Every_Digit 1. oneliner for loop, .join()
10 2022-12-22 7_kyu_Jaden_Casing_Strings 1. for loop oneliner, join(), .capitalize(), .split(), .rstrip()
2. same, but this time I figured out about 'SEPORATOR'.join()
11 2022-12-23 7_kyu_Highest_and_Lowest 1. map(), f-string, max(), min()
12 2022-12-24 7_kyu_Beginner_Series_#3_Sum_of_Numbers range(), oneliner
13 2022-12-26 7_kyu_Exes_and_Ohs 1. if-else oneliner, count(), lower()
2. (FC) same but without if/else
3. More readable version
14 2022-12-27 7_kyu_Growth_of_a_Population 1. while loop, round down by //
2. (FC) addition argument, no round
15 2022-12-28 8_kyu_Basic_Mathematical_Operations 1 eval(), f-string. eval() with open argument - unsecure practice
2. dict insted of if
16 2022-12-29 6_kyu_Detect_Pangram 1. for, if, rfind(), chr(), unicode_index
2. (FC) import string, oneliner, set(), issubset(), string.ascii_lowercase
17 2023-01-29 6_kyu_Array.diff 1. List comprehension, in/not in / for loop
2. (FC) Same but subtrahend list converted to set(). More efficient.
18 2023-01-29 6_kyu_Replace_With_Alphabet_Position 1. Unicode, ord(), .join(), for/if oneliner
19 2023-01-30 8_kyu_DNA_to_RNA_Conversion 1. translation() - with dic it takes ASCII id / for loop
2. replace()
20 2023-02-05 7_kyu_Mumbling 1. for loop oneliner, enumerate(), join(), .capitalize()
21 2023-03-13 6_kyu_Break_camelCase.py 1. RegEx
2. (FC) RegEx, re.sub()
22 2023-03-14 6_kyu_Duplicate_Encoder.py 1. collections.Counter()
23 2023-03-15 5_kyu_Valid_Parentheses.py 1. Two counters algorithm
2. (FC) One counter realisation (much cleaner)
24 2023-03-16 8_kyu_A_Needle_in_the_Haystack.py 1. f-string, index()
25 2023-03-18 7_kyu_Isograms.py 1. for, enumerate, O(n^2)
2. (FC) set(). O(n)
26 2023-03-20
2025-10-214
6_kyu_Counting_Duplicates.py 1. dict, two for loops
2. iterator and set()
3. (FC) for loop, seen and dupes sets (nice one)
4. (My) for, .lower, set(), counter var
5. (My) Counter from collections, sum(), generator
27 2023-03-22 7_kyu_Sum_of_two_lowest_positive_integers.py 1. sorted(), sum(), O(n log n)
2. smallest & sec_smallest, for, sum(), O(n)
28 2023-03-24 8_kyu_Rock_Paper_Scissors.py 1. if-elif-else construction, easy to read
29 2023-03-30 7_kyu_Get_the_Middle_Character.py 1. if-elif-else, slice
2. (FC) divmod(), if-else oneliner, slice (much better than 1)
30 2023-04-11 6_kyu_Find_the_odd_int.py 1. collections - Counter, for k,v
31 2023-04-26 7_kyu_Vowel_Count.py 1. collections.Counter, for loop
2. (FC) sum(), in-for-in oneliner
32 2023-05-08 8_kyu_Reversed_Strings.py 1. slice [::-1]
33 2023-05-08 8_kyu_Grasshopper_-_Check_for_factor.py 1. statement %
2. return if else (no need for that. 1 variant did the same thing)
34 2023-05-09 8_kyu_Remove_exclamation_marks.py 1. .replace()
35 2023-05-09 8_kyu_Cat_years,_Dog_years.py 1. if * 3
2.
36 2024-08-14 6_kyu_Sort_the_odd.py 1. list, append(), sort()
37 2024-10-23 8_kyu_Sentence_Smash.py 1. join(), strip()()
38 2024-10-23 8_kyu_Calculate_BMI.py Tuple() insead of list[] for efficiency. One return statement instead of 4.()
39 2024-09-12 6_kyu_Count_characters_in_your_string.py 1. for-loop, if-else
2. (FC) for-loop, dict.get(value, default)
40 2024-10-12 7_kyu_Disemvowel_Trolls.py 1. (FC) ''.join(), list comprehansion
2. (FC) re, re.sub()
41 2025-07-08 8_kyu_Super_Duper_Easy.py 1. try/except
42 2025-07-10 6_kyu_Simple_Encryption_#1_-_Alternating_Split.py 1. slice [:], for-loop, % 2. OK, but can be better
2. (FC) Advanced slicing and multiple assigment
43 2025-07-15 6_kyu_Who_likes_it.py 1. if-elif, .join()
2. (FC) dict, .format(), [:] better looking, but worse efficiency
44 2025-07-17 8_kyu_Reverse_List_Order.py 1. [::-1]
45 2025-07-17 8_kyu_Convert_a_String_to_a_Number.py 1. int()
46 2025-07-22 7_kyu_Remove_anchor_from_URL.py 1. .split()[]
47 2025-07-24 8_kyu_Transportation_on_vacation.py 1. CONST, dict very readable
48 2025-07-24 8_kyu_You_only_need_one_-_Beginner.py 1. elem in seq
49 2025-07-28 8_kyu_Beginner_-_Lost_Without_a_Map.py 1. list comprehansion
50 2025-07-28 8_kyu_Total_amount_of_points.py 1. list comprehansion
51 2025-07-31 7_kyu_Sum_of_odd_numbers.py 1. for-loops, list, .apend()
2. (FC) n ** 3... yes.
52 2025-08-04 7_kyu_Find_the_capitals.py 1. list comprehansion, range(len()), str.isupper()
2. (FC) better list comprehansion, enumerate(), str.isupper()
53 2025-08-20 6_kyu_Your_order,_please.py split(), list comprehansion, for-loops, if, key-value in dict.items(), join()
54 2025-08-20 8_kyu_get_character_from_ASCII_Value.py 1. chr()
55 2025-08-20 7_kyu_Testing_1-2-3.py list comprehansion, enumerate() with start parameter
56 2025-08-20 6_kyu_Consecutive_strings.py 1. generator + max(key=len), ''.join
2. nested loops + max(key=len)
57 2025-08-21 6_kyu_Give_me_a_Diamond.py 1. for-loop, abs distance to diamond mid abs(mid - i), stars and spaces counting, .append(), join()
2. (FC) nice&easy. Make mid and add similar lines from both sides
58 2025-08-22 6_kyu_Tribonacci.py 1. for-loop, condition checks for n, sum() slice
2. (FC) short loop with res[-3:]
59 2025-09-02 8_kyu_Parse_nice_int_from_char_problem.py int(), string indexing [0]
60 2025-09-02 8_kyu_Find_Maximum_and_Minimum_Values_of_a_List.py min(), max() built-in functions
61 2025-09-02 8_kyu_Keep_up_the_hoop.py 1. tuple indexing with boolean 2. ternary operator 3. if-else statement
62 2025-09-02 7_kyu_Sum_of_the_first_nth_term_of_Series.py list comprehension, sum(), f-string formatting :.2f
63 2025-09-02 8_kyu_Return_Negative.py abs(), unary minus operator
64 2025-09-05 8_kyu_altERnaTIng_cAsE_ALTerNAtiNG_CaSe.py 1. generator expression, casefold(), isupper(), upper() 2. (FC) string.swapcase() - built-in method
65 2025-09-05 8_kyu_Powers_of_2.py list comprehension, range(), power operator **
66 2025-09-08 8_kyu_Convert_number_to_reversed_array_of_digits.py list comprehension, str(), int(), slice reversal [::-1]
67 2025-09-09 5_kyu_Directions_Reduction.py stack data structure, dictionary, list.pop(), list.append(), type hints
68 2025-09-10 8_kyu_Finish_Guess_the_Number_Game.py class, init, instance variables, method, type hints, exception handling
69 2025-09-24 7_kyu_Refactored_Greeting.py class, init, instance method, f-string, type hints, OOP
70 2025-09-27 8_kyu_Get_Planet_Name_By_ID.py 1. dictionary mapping, dict.get()
71 2025-10-01 6_kyu_Stop_gninnipS_My_sdroW.py 1. generator, [::-1], len(), .split()
2. for loop
3. (AI): map(), lambda, .split()
72 2025-10-02 7_kyu_Descending_Order.py sorted(), str(), int(), ''.join()
73 2025-10-03 8_kyu_Name_Your_Python.py class, init, instance variable
74 2025-10-06 8_kyu_Regular_Ball_Super_Ball.py class, init, default parameter, instance variable
75 2025-10-09 6_kyu_Sum_of_Digits_Digital_Root.py 1. mathematical modulo 9 approach
2. (FC) clever one-liner with boolean operators or and
76 2025-10-13 7_kyu_Basic_Sequence_Practice.py 1. iterative cumulative sum, edge case handling
2.(AI) mathematical triangular numbers

LeetCode


Date File Theme
1 2022-11-17 06_Remove_Element.py Arrays_101
1. two pointers: fast and slow
2. two pointers (start and end) and swap
2 2022-11-19 07_Remove_Duplicates_from_Sorted_Array.py Arrays_101
1. two pointers, slow and fast + while loop
2. (FC) One pointer + for loop, pretty close to 1 solvation
3 2022-11-21 08_Check_If_N_and_Its_Double_Exist.py Arrays_101
1. set(), for, in
4 2022-11-23 09_Valid_Mountain_Array.py Arrays_101
1. while loop, walk up - walk down
5 2023-06-02 01_1768._Merge_Strings_Alternately.py LeetCode_75
1. two pointers
2. (FC) zip_longest, list comprehansion, "".join
6 2023-08-11 02_1071._Greatest_Common_Divisor_of_Strings.py LeetCode_75
1. (My, did't work) max(), min(), for-loop, count()
2. (Editoiral) / Brute Force - prefix check, end-to-start, min(), len()
7 2023-09-01 03_1431._Kids_With_the_Greatest_Number_of_Candies.py LeetCode_75
1. (My) max(), for-loop, append()
2. (From Comments, much shorter!), max(), generator expression
8 2025-03-14 max_consecutive_ones.py Arrays_101
1. pointers
2. Counter

About

My CodeWars and LeetCode solutions archive #python

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages