Visual illustration of the code challenge: Petits monstres mignons #4

Petits monstres mignons #4

Revoilà les petits monstres, ils ont bien mangé, ils ont quitté le repas, et maintenant… ils se rapprochent…

Coding in the sandbox You must be logged in to access the sandbox.

Mission

Revoilà les petits monstres, ils ont bien mangé, ils ont quitté le repas, et maintenant… on dirait qu’ils se mettent à former des couples…

Règles

Les petits monstres se mettent en couple, 2 par 2, de la façon suivante :

  • Les petits monstres de type Fruits (F) avec les petits monstres de type Rock (R)
  • Les petits monstres de type Wood (W) avec les petits monstres de type Grass (G)

Chaque couple est formé de 2 petits monstres différents : « F+R » ou « W+G »

Il va falloir trouver l’indice de rapprochement, qui se calcule de la façon suivante :

Couples FR * Couples WG + petits monstres seuls

Par exemple, si j’ai ces monstres : FGGWRRFFFRGW, j’ai :

  • 3 couples FR : FGGWRRFFFRGW
  • 2 couples GW : FGGWRRFFFRGW
  • 2 petits monstres seuls : 1F et 1G

L’indice est donc 3 * 2 + 2 soit 8.

Tu dois retourner l’indice de rapprochement.

Important :

  • Il y a toujours au moins 1 monstre de chaque type dans la liste
  • La proximité ou l’ordre des monstres dans la liste n’a aucune importance dans ce challenge.

Solve the challenge

To code this challenge, several possibilities:
- Want to start coding right away? Use the online Sandbox.
- Want to work in your favorite editor? Organize your code well, test, check out our API documentation.
- You can also copy/paste a dataset below.

challenge code for resolution via API: MONSTERS_4

Some resources to help you:
Data and algorithmic logic Methodologies Corrections

Support for resolution

Progress through challenges using our resolution aids: tools, techniques and advice to help you overcome the most complex programming challenges with methodology, confidence and creativity.

Dataset and algorithmic logic

Based on the data and the expected response, use the process to determine the logic to implement.

Show data and progress

Methodologies

Develop a structured approach with our solving guides. Work on specific concepts such as object-oriented programming or unit testing to improve your coding style and progress.

No methodology yet for this challenge, but we are working on it! Follow us to be informed of the release!


Corrections

The corrections allow you to discover certain technical concepts but will also give you a solution to the challenge. Code the challenge yourself before consulting the corrections ;)

No answer yet for this challenge, but we&'re working on it! Follow us to be informed of the release!

Programming concept(s) that can be used to solve this challenge: Conditions, Tableaux

Keep coding

Other challenges to complete

Beginner
Coupe du monde de rugby #1 La mêlée

Coupe du monde de rugby #1 La mêlée

La mêlée, ce temps fort d’un match de rugby ! Calcule la puissance de l’impact !

Calculation Corrigé disponible : PHP
Beginner
#1 : Le grand saut

#1 : Le grand saut

Ada vient de tweeter son oeuvre et est tout de suite reprise par plusieurs comptes. On cherche à connaitre l’audience totale.

Calculation
Beginner
AlgoPark #2 : la grande Roue

AlgoPark #2 : la grande Roue

Analyse le fonctionnement de la grande roue pour rentrer davantage dans les méandres du parc !

Calculation