Skip to content

Freihart512/prueba-repl

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 

Repository files navigation

prueba-repl

Exercises:



Cycle Detection

A linked list is a linear collection of data elements, whose order is not given by their physical placement in memory. Instead, each element points to the next. It is a data structure consisting of a collection of nodes which together represent a sequence. In its most basic form, each node contains: data, and a reference (in other words, a link) to the next node in the sequence.

linked list

A linked list is said to contain a cycle if any node is visited more than once while traversing the list.

cycled linked list

What you need to do...

  1. Create a data structure that will be used for your linked list.
  2. Create function that will receive one parameter:
    • head := A node structure/object that is the head of a linked list.
  3. Your function must return a boolean denoting whether or not there is a cycle in the list. If there is a cycle, return true; otherwise, return false.



Diagonal Sum

Given a matrix F of size n by m (where: m >= n) filled with integer numbers you can calculate a diagonal sum by summing all of the numbers starting from one of the corners (a, b, c, d) in F following a diagonal path until you reach the last number in the diagonal line.

matrix corners

Example:

diagonal sum 1

In this case we start at corner c of a matrix of size n=3 by m=4, which has the diagonal numbers: [3, -7, -3]. The sum of all these numbers is: 3 + (-7) + (-3) = -7.

Our diagonal sum result is -7.

Another Example:

diagonal sum 2

In this case we start at corner a of a matrix of size n=3 by m=3, which has the diagonal numbers: [-4, 8, 7]. The sum of all these numbers is: -4 + 8 + 7 = 11.

Our diagonal sum result is 11.

What you need to do...

  1. Create a function named diagonalSum that receives two arguments:
    1. matrix:= An Array[][] of size n by m: Array[n][m].
    2. corner := A character that represents the corner (a, b, c, d).
  2. The function diagonalSum(matrix, corner) must return an integer number, the diagonal sum result.



Round Robin Tournament

A round-robin tournament (or all-play-all tournament) is a competition in which each contestant meets all other contestants in turn. Also if there are several contestants is common to create groups that runs their own round robin tournament per group.

Group A

Example of a round robin tournament: Group A results.



Group B

Example of a round robin tournament: Group B results.

A tournament can have g number of groups and each group can have c number of contestants. Not all of the groups will have the same number of contestants, for example Group C (no picture for this group) will have 6 contestants instead of 5 which Group A has.

The total number of matches that can happen in a given group is calculated by:

matches formula

Note that each match has a score, it's not just a win or a lose.

At the end of a round robin tournament (or a group tournament) the sum of all of the scores in which a contestant T participated will be used to determine the final position of the contestant T. The contestant with the best score will be placed first, then the second best score and so on.

Example of results:

Group A

Group A positions

The sum of the scores in which a particular contestant participated it's shown to the right of the row:

scores

Both numbers represent the score at the end of the tournament, the black number is a minified & rounded version and the grey one is the score without any modification. The grey score is the one that we want and we will call it final score.

The final score can be calculated by getting the sum of all scores of the matches in which a contestant participated.

What you need to do...

  1. Design a data structure that can hold the results of all of the groups and matches with the score.
  2. Create a function that allows to report a result of a match (score).
  3. Create a function that given a contestant name, returns the position and the final score of that contestant.



Le Sammy Sequence

A linked list is a linear collection of data elements, whose order is not given by their physical placement in memory. Instead, each element points to the next. It is a data structure consisting of a collection of nodes which together represent a sequence. In its most basic form, each node contains: data, and a reference (in other words, a link) to the next node in the sequence.

linked list

Given a linked list, the sum of all consecutive nodes that results in a 0 (zero) will be called Le Sammy sequence.

Example of Le Sammy sequence:

3 -> 4 -> -7 -> 5 -> -6 -> 6

In the above case you should first remove 3 -> 4 -> -7, then -6 -> 6, leaving only 5.

What you need to do...

  1. Create a function that given a linked list, removes the presence of all Le Sammy sequence (basically removes all the consecutive nodes that sum zero).




Thank you! 😊

scores

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published