Created
April 20, 2024 18:50
-
-
Save altherlex/1ade627b2e4a89bbc4162bbb73bd5db3 to your computer and use it in GitHub Desktop.
Code assesment for Dataannotation: python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Script for https://app.dataannotation.tech/workers/starter_assessment_complete | |
# Instructions: https://github.com/altherlex/firekamp/blob/main/app/assets/dataannotation-assessment.png | |
# File: https://github.com/altherlex/firekamp/blob/main/app/assets/coding_qual_input.txt | |
def create_staircase(nums): | |
step = 1 | |
subsets = [] | |
while len(nums) != 0: | |
if len(nums) >= step: | |
subsets.append(nums[0:step]) | |
nums = nums[step:] | |
step += 1 | |
else: | |
return False | |
return subsets | |
# DOC: Read the file and splits de content by line and number. | |
path = '/Users/altheralves/Downloads/coding_qual_input.txt' | |
file = open(path, "r") | |
content = file.read().splitlines() | |
# DOC: Splited by line. coupled_content has [['193', 'land'], ...] | |
coupled_content = [line.split() for line in content] | |
# DOC: list_of_numbers has every number. | |
list_of_numbers = [int(item[0]) for item in coupled_content] | |
list_of_numbers.sort() | |
# DOC: Calculates the indexes for each line of the pyramide | |
begin = 0 | |
# DOC: indexes has [1, 3, 6, 10, 15, 21, 28, 36, ...] | |
# indexes = create_staircase(list_of_numbers) | |
# print(indexes) | |
indexes = [] | |
for item in list_of_numbers: | |
sub_list = list_of_numbers[begin:item+begin] | |
begin = item+begin | |
if sub_list == []: | |
break | |
else: | |
indexes.append(sub_list[-1]) | |
print(indexes) | |
phrase = [] | |
for index in indexes: | |
for line in coupled_content: | |
if int(line[0]) == index: | |
phrase.append(line[1]) | |
break | |
print(' '.join(phrase)) | |
# ➜ [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120, 136, 153, 171, 190, 210, 231, 253, 276, 300] | |
# ➜ design all skill whole check deal wish visit now moment offer planet people electric lot huge system card current man way our parent wait |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment