Programming exercises

# Description Tags Difficulty Link
26 Given a table and the name of a column in the table, you sort the rows of the table according to the values contained in the column, you return the number of columns in the table. Dictionaries,Sorting,Lists 2 Download
27 Given a table, a table column name and a value, delete rows that have a different value for that column and delete the column, the number of rows deleted is returned Lists,Dictionaries 2 Download
28 Given a table, the name of a column, and a value, returns the table without the indicated column and without the rows with a value different from the one indicated Lists,Dictionaries 2 Download
30 Given 3 paths to text file, decode the message contained in the first file via the second file and save the decoded text in the third file, return the number of characters that could not be decoded Files,Strings 2 Download
48 Given a tree of type AlberoBinario, it returns the number of nodes that have exactly 2 children. Trees,Recursion 2 Download
54 Given as input a list of integers and strings, delete the strings from the list and return a dictionary with keys the deleted strings. Dictionaries,Lists 2 Download
68 Given a path to a directory and a list of extensions, the function, recursively, searches the directory and its subdirectories for files with list extensions, returns a dictionary with extension keys and values the number of files found. File Search,Recursion 2 Download
7 Takes a tree, a set of characters and an integer as inputs, and returns the number of tree nodes having exactly the integer number of child nodes present in the input set Trees,Recursion 3 Download
8 It takes a set of words into input, returns the ordered list of all the words you can create by merging the words into the starting set Sorting,Strings 3 Download
9 Given the name of a directory as input, return a list of pairs (subdir name, bytes occupied by all the .txt files in that subdir), sorted by space and, then, by subdir name Recursion,Files,Sorting 3 Download
10 Given a file with one word per line and a number k, returns the word composed of the letters of the words with length k, taking for each position the letter that appears most often in the words File,Strings,Dictionaries,Sorting 3 Download
11 Given a text file containing strings, return a dictionary with key a string without vowels and attribute a list of strings, which generated the key Files,Sorting,Strings,Dictionries 3 Download
12 Given an integer k, build a binary tree complete with height k, the leaves with value from 1 to 2^k and the inner nodes with value the sum of the two children values. Recursion,Trees 3 Download
16 Given as input an s string and an integer k, return an ordered list containing the different s sub-strings in which exactly k distinct characters appear Lists,Strings,Sorting 3 Download
18 Dati in input 2 dizionari, ritorno un dizionario con chiavi, le chiavi in comune ai due dizionari, e valore una tupla di due valori, il primo l'unione e il secondo l'intersezione dei valori della chiave nei due dizionari Dizionari,Insiemi 3 Download
36 Take as input a list of dictionaries, return a dictionary with keys, keys common to all dictionaries, and values, values common to all keys Dictionaries,Sorting 3 Download
37 Given as input a list of dictionaries, return a dictionary with keys, common keys at least half of the dictionaries, and values a set of integers. Dictionaries,Sets 3 Download
42 Given as inputs 3 files, 2 images and a text file, modifies some pixels of the first image, specified in the text file, and saves the new image in the second image, returns the number of pixels modified. File,Images 3 Download
43 When you input a text file containing integers, it returns a list of integers that are the sum of the integers in the file File,Strings 3 Download
50 Given a string of digits s and an integer k, returns the list of sub-strings of s long k that have the characters in strictly increasing order Strings,Sorting 3 Download
51 Given in input a list of words ls and a character c, delete from ls all words that contain c, return the number of deleted words Strings,Lists 3 Download
62 Given a matrix of integers, find the coordinates of the minimum and maximum value of the matrix, create a new matrix where the rows and columns of the two values are swapped, return the new matrix. Matrices 3 Download
63 Given as input two file names, one containing words and the other to be created, the function for each word in the first file, creates a trio (a, b, c) and writes it in the second file, returns the total number of characters in file 1, except spaces and carriage return. Files,Strings 3 Download
69 Dati un path di una directory, un intero che rappresenta la profondità e una lista di estensioni, cerca i file nella directory e nelle sue sotto directory, ricorsivamente, se il file ha una delle estensioni della lista ed è alla profondità indicata, elimina il file. Torna il numero totale di file presenti nelle directory con profondità uguale o minore alla profondità data. Ricerca File,Ricorsione 3 Download
71 Given one directory path and two integers, min and max, recursively search in the directory for files between min and max size. Return the dictionary with the found files as keys and the depth in which the file was found as value. File Search,Recursion 3 Download
76 Given a string, the recursively function calculates the suffixes of the string, returns the suffix list. Recursion,Strings 3 Download
77 Given a character string, without using recursion, the function returns the suffix list of the string. Strings 3 Download
2 It takes a list of strings and a text file as input, removes from the list the strings that can be obtained by concatenating two string read from the file, returns the number of strings removed from the list Strings,File 4 Download
3 It takes two sets of natural numbers as input, returns a list of triples (a, b, c) such that: a, b and c are in the first input set, a < b < c, and (a + b + c) is in the second input set Sets,Sorting,Lists 4 Download
13 Modify the color of an image in a .png file and save the obtained image in a second file, return the number of distinct colors of the image Images 4 Download
20 Transformation of a string into a number by summing character values Strings 4 Download
21 Given a character matrix, returns a new matrix with the columns in lexicographic order respect to the input matrix Matrices,Sorting 4 Download
29 Given two tables having the same structure and the name of a column, with respect to which the tables are ordered, insert in table 1 rows of table 2, returns the number of rows inserted Lists,Dictionaries,Sorting 4 Download
31 Given two paths to text files, transform the strings contained in the first file and save the result in the second file, return the number of modified characters. File,Strings 4 Download
32 Given a json file, retunr a list of tuples (A, B) Json,Files,Strings 4 Download
35 Given a path to a directory and a set of words, returns a dictionary of the words contained in the .txt files within the directory File,File Search,Dictionaries 4 Download
41 When you input a text file containing a list of integers, it returns the number that appears most frequently in the sequence derived from S Files,Strings,Dictionaries 4 Download
55 Given a character, two integers and a matrix, returns the tuple with the minimum and maximum between the elements of the matrix, switch the rows or columns of the matrix indicated by the two integers in input. Matrices 4 Download
56 Given a table of integers, return the list of integers that occur the maximum number of times in the table, and replaces them with '*'. Matrices 4 Download
58 Given a list of strings representing robot moves as chars in the set {'N', 'S', 'E', 'O'}, modify the list by removing the strings and putting integer numbers, return the total number of characters in the list. Lists,Strings 4 Download
59 Given a text file with integer rows inside, it returns a string of '0' or '1', at the i-th position the string contains '1' if the sum of the integers of the i-th row of the file is odd. File,Strings 4 Download
64 Given in input a list of integers, produces a string with the numbers of the list vertically, one digit per line. Strings,Lists 4 Download
70 Given a path to a directory, a list of file extensions and a list of strings, search in the directory, recursively, how many times the list strings are present in the files that do not have extensions in the list, a dictionary returns with the results. File Search,Recursion,Files 4 Download
4 It takes as input an image, a path, and two numbers, modifies the image according to the two numbers, saves the image to the path and returns the color that appears most often in the image Images 5 Download
22 Given a PNG file and a JSON file, read the PNG file and encode it in an array of strings, each pixel becomes a string of 9 characters, save the encoded array in the JSON file and return the lexicographically smaller string, among those that appear in the array with higher frequency Matrices,Images,Strings 5 Download
23 Given a JSON file and a PNG file, extract the matrix from the JSON file, the matrix is composed of pixels encoded in 9 character strings, decode the pixels and save them in the PNG file, return the color that appears most often Strings,Matrices,Images 5 Download
39 Given an integer n and a path to a json file, you build a spiral matrix of order n and save it in the json file, return the sum of the values in the even index columns Matrices,Json 5 Download
40 Input a json file containing a matrix and an integer k, search within the matrix a square of side k, return the coordinates of the square or (-1,-1) otherwise Json,Matrices 5 Download
78 Given a character string, it returns the list of 'growing substrings', using a recursive function. Strings,Recursion,Sorting 5 Download
79 Data una lista che può essere vuota, contenere interi e avere a suo volta liste del suo stesso tipo, la funzione ricorsivamente inverte la lista e quelle che contiene, ritorna una tupla di 3 elementi. Ricorsione,Liste 5 Download
1 Given two BinaryTree objects, build a third BinaryTree object with the same structure as that of the input trees and the values computed as the sum of the subtrees’ nodes values, then return its root. Recursion,Trees 6 Download
5 Takes as input a set of strings and an integer k, returns a set containing the different strings that can be obtained by concatenating k times the strings in the input set Recursion,Sets,Strings 6 Download
14 Given a binary tree and an integer x as inputs, returns the number of tree nodes divisible by x + level Recursion,Trees 6 Download
15 Given two images with different dimensions, create a third image following a simple rule and save it in a new file and return the number of black pixels present in both images Images,Files 6 Download
17 Given a list of words and an integer k, delete words that contain at least k equal characters from the list, return the number of deleted words from the list Lists,Strings 6 Download
19 Given a file with a 2-dimensional array inside, return a tuple of two values, the first: the 2-d array in the form of a list of lists, the second: the sum of the frame values File,Strings,Matrices 6 Download
24 Given a file and a list of characters, returns a list of tuples, each tuple consisting of a character in the input list and the percentage of occurrences of the character in the file. Files,Strings,Lists,Sorting 6 Download
25 Given an integer n, calculate and return the n-th row of the Tartaglia's triangle Recursion,Lists 6 Download
33 Given as input two paths to text files, takes the text in the first file, builds a histogram with the frequency of characters in the text and saves the histogram in the second file, returns the number of lines in the histogram File,Strings,Sorting 6 Download
34 Given two paths to json files, the first file contains an incomplete Latin square in the form of a list of lists, complete the Latin square and save it in the second json file, return the set of symbols that appear in the square Matrices,Files,Json 6 Download
44 Given as an input two integers a and b, return the set of the first a integers that have exactly b dividers. Sets 6 Download
45 Taken an input two strings, returns the list of substrings common to both strings Strings,Sets,Sorting 6 Download
46 Given as input a string, returns the substring of maximum palindrome length Strings,Recursion 6 Download
47 Given a list of strings as an input, return a sorted list without duplicates Strings,Sorting 6 Download
49 It takes the address of three png files, creates an image from the images contained in the first two png files and saves it in the third address, returns the number of pixels so r+g+b is an odd number. Images 6 Download
52 Give two sparse matrices of equal size, return a third sparse matrix, sum of the two input matrices. Matrices,Dictionaries 6 Download
53 Given a file as input, returns a dictionary with integer as keys and integer list as attributes. File,Dictionaries 6 Download
57 Given a grid NxN, if the grid represents a skyscraper puzzle, it returns the 4 lists North, East South, West, otherwise it returns 4 empty lists Matrices 6 Download
60 Dati in input due file, la funzione modifica la matrice contenuta nel primo file e la salva nel secondo, torna un intero. Files,Matrices 6 Download
65 Given an integer k, a list of squares (represented by a sestuple (x, y, l, r, g, b)), and a path where to save the image, the function creates a square image of side k, draws on it the squares represented in the list and saves the image obtained at the input path, returns the number of black pixels of the image Images,Matrices 6 Download
72 Given a path to a directory and a path to a json file, it recursively reads the contents of the directory and builds a dictionary to be saved in the json file. It returns the maximum number of files contained in one of the directories. Recursion,Dictionaries,Files,Json 6 Download
73 Given the path to a directory and the path to an html file, the function recursively reads the contents of the directory and builds the tree of the directory structure in html, saves the tree in the input html file, returns the built tree. Trees,File,File Search,Html 6 Download
74 Given a Png image, the coordinates of a point, a thickness, a list of colors and a path to another Png image, the function draws a series of rings over the Png image, with the center of the coordinates of the input point, then saves the image to the second Png file, returns the list with the number of colored pixels for each color. Images,Matrices 6 Download
80 Given a path to a directory and a set of words ( character strings between 'a' and 'z'), the search function in the directory and its subdirectories for any .txt files with words contained in the set passed in input, returns a dictionary of found words. File Search,Files 6 Download
6 It takes as input a set of strings, each one represents a leaf-root path in a binary tree, where each node contains a letter, returns the binary tree Trees,Recursion,Strings 7 Download
38 Given a maze, in the form of a list of lists, returns the coordinates (x, y) of the lowest and rightmost cell, reachable from the cell (0, 0) Matrices 8 Download
61 Given a text file as input, containing a matrix of integers, an operation and a parameter sel, which specifies on what to apply the operation, returns a list of integers. Matrices,File 8 Download
75 given a height, a width, a color list, a list of heights, a width, and a path to a Png file, creates a blue background image and draws on it rectangles with different heights, returns the number of pixels that belong to more than one rectangle. Images,Matrices 8 Download
66 Given a BinaryTree, return the maximum width of the tree, i.e. the difference between the positions of the rightmost and the leftmost nodes of the tree. Trees,Recursion 9 Download
67 Given a path in the filesystem, the function recursively explores the corresponding directory and returns a dictionary with the found file extensions as keys and an integer as values. Recursion,File Search,Dictionaries 9 Download