The data used within this project is my set of solutions to kata on Codewars. I have been using Codewars for a few months now and have solved around 600 kata.
To collect data I use a combination of scraping to get my solutions set, along with the Codewars API to collect additional data about the kata.
The data set is as such, ever evolving as I solve more kata and other people may use the scraper and API to collect their own data to use in this project.
Analyse the languages used in the kata I have solved and the number of kata solved in each language.
The first Kata I ever solved was on the 7th March 2023. From then on, I've explored a variety of languages, with Python being the first language I used to solve a kata. This chart shows the first time I solved a kata in each language.
This chart shows how the number of kata solved in each language has changed over time.
The following chart shows the completion ratio of kata I have solved. The completion ratio is the number of people who have solved the kata divided by the number of people who have attempted the kata.
import math def justify(text, width): words = text.split() line = "" lines =  line_num = 0 for word in words: word.rstrip() if len(line) + len(word) <= width: line += word + " " else: # strip whitespace from end of line and calculate how much remaining space there is line = line.rstrip() remaining_space = width - len(line) print("Line " + str(line_num) + ": " + line) print("Line length: " + str(len(line))) print("Remaining space" + str(remaining_space)) if remaining_space == 0: lines.append(line + "\n") line = word + " " continue # split line into words line_words = line.split() # if there is only one word in the line, just continue because lines shouldn't end with a space if len(line_words) == 1: lines.append(line + "\n") line = word + " " continue # calculate how much extra space to add per word extra_spaces = math.floor(remaining_space / (len(line_words) - 1)) # There may be an error because of flooring this number, so calculate how many gaps will have an extra space extra_space_gaps = remaining_space - \ extra_spaces * (len(line_words) - 1) print(extra_space_gaps) # large gaps go first - clear line and start adding words and spaces line = "" for words in line_words[:-1]: line += words + " " if extra_space_gaps > 0: line += " " extra_space_gaps -= 1 line += (" " * extra_spaces) # add last word to line line += line_words[-1] + "\n" # add line to lines list lines.append(line) # reset line line = word + " " # add last line to lines list lines.append(line.rstrip()) return "".join(lines).rstrip()
import numpy as np def max_sum(arr): arr = np.array(arr) max_sum = -1 max_subarray =  rows, cols = arr.shape for start_row in range(rows): row_sums = np.zeros(cols) for end_row in range(start_row, rows): row_sums += arr[end_row] # Apply Kadane's algorithm to find the maximum sum subarray in the 1D array current_sum = 0 max_sum_so_far = 0 start_col = 0 end_col = 0 for j, num in enumerate(row_sums): current_sum += num if current_sum < 0: current_sum = 0 start_col = j + 1 elif current_sum > max_sum_so_far: max_sum_so_far = current_sum end_col = j # Check if the current subarray has the maximum sum if max_sum_so_far > max_sum: max_sum = max_sum_so_far max_subarray = [start_col, start_row, end_col, end_row] return max_subarray + [max_sum]
# TODO: create the User class # it must support rank, progress, and the inc_progress(rank) method ranks = [-8, -7, -6, -5, -4, -3, -2, -1, 1, 2, 3, 4, 5, 6, 7, 8] class User: def __init__(self): self.rank = -8 self.progress = 0 def inc_progress(self, rank): rank_pos = ranks.index(self.rank) challenge_rank_pos = ranks.index(rank) diff = challenge_rank_pos - rank_pos progress = 0 if diff == -1: progress = 1 elif diff == 0: progress = 3 elif diff > 0: progress = 10 * diff * diff self.progress += progress while self.progress >= 100: try: self.rank = ranks[ranks.index(self.rank) + 1] self.progress -= 100 except: self.rank = ranks[len(ranks) - 1] self.progress = 0 break if self.rank == 8: self.progress = 0