chore(i18n,curriculum): update translations (#43167)
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d8250367417b2b2512c5f
|
||||
title: Create a Stack Class
|
||||
title: Creare una classe Stack
|
||||
challengeType: 1
|
||||
forumTopicId: 301633
|
||||
dashedName: create-a-stack-class
|
||||
@ -8,15 +8,15 @@ dashedName: create-a-stack-class
|
||||
|
||||
# --description--
|
||||
|
||||
In the last section, we talked about what a stack is and how we can use an array to represent a stack. In this section, we will be creating our own stack class. Although you can use arrays to create stacks, sometimes it is best to limit the amount of control we have with our stacks. Apart from the `push` and `pop` method, stacks have other useful methods. Let's add a `peek`, `isEmpty`, and `clear` method to our stack class.
|
||||
Nell'ultima sezione, abbiamo parlato di cosa è uno stack (pila) e come possiamo usare un array per rappresentarlo. In questa sezione, creeremo la nostra classe stack. Anche se è possibile utilizzare degli array per creare gli stack, a volte è meglio limitare la quantità di controllo che abbiamo sui nostri stack. Oltre al metodo `push` e `pop`, gli stack hanno altri metodi utili. Aggiungiamo un metodo `peek`, `isEmpty`e `clear` alla nostra classe stack.
|
||||
|
||||
# --instructions--
|
||||
|
||||
Write a `push` method that pushes an element to the top of the stack, a `pop` method that removes and returns the element on the top of the stack, a `peek` method that looks at the top element in the stack, an `isEmpty` method that checks if the stack is empty, and a `clear` method that removes all elements from the stack. Normally stacks don't have this, but we've added a `print` helper method that console logs the collection.
|
||||
Scrivi un metodo `push` che inserisce un elemento in cima allo stack, un metodo `pop` che rimuove e restituisce l'elemento in cima allo stack, un metodo `peek` che guarda l'elemento in cima allo stack, un metodo `isEmpty` che controlla se lo stack è vuoto, e un metodo `clear` che rimuove tutti gli elementi dallo stack. Normalmente gli stack non hanno questo, ma abbiamo aggiunto un metodo di aiuto `print` che visualizza la collezione nella console.
|
||||
|
||||
# --hints--
|
||||
|
||||
Your `Stack` class should have a `push` method.
|
||||
La tua classe `Stack` dovrebbe avere un metodo `push`.
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -27,7 +27,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
Your `Stack` class should have a `pop` method.
|
||||
La tua classe `Stack` dovrebbe avere un metodo `pop`.
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -38,7 +38,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
Your `Stack` class should have a `peek` method.
|
||||
La tua classe `Stack` dovrebbe avere un metodo `peek`.
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -49,7 +49,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
Your `Stack` class should have a `isEmpty` method.
|
||||
La tua classe `Stack` dovrebbe avere un metodo `isEmpty`.
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -60,7 +60,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
Your `Stack` class should have a `clear` method.
|
||||
La tua classe `Stack` dovrebbe avere un metodo `clear`.
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -71,7 +71,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
The `peek` method should return the top element of the stack
|
||||
Il metodo `peek` dovrebbe restituire l'elemento in cima allo stack
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -84,7 +84,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
The `pop` method should remove and return the top element of the stack
|
||||
Il metodo `pop` dovrebbe rimuovere e restituire l'elemento in cima allo stack
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -97,7 +97,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
The `isEmpty` method should return true if a stack does not contain any elements
|
||||
Il metodo `isEmpty` dovrebbe restituire true se uno stack non contiene alcun elemento
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -108,7 +108,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
The `clear` method should remove all element from the stack
|
||||
Il metodo `clear` dovrebbe rimuovere tutti gli elementi dallo stack
|
||||
|
||||
```js
|
||||
assert(
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d8258367417b2b2512c82
|
||||
title: Delete a Node with Two Children in a Binary Search Tree
|
||||
title: Eliminare un nodo con due figli in un albero binario di ricerca
|
||||
challengeType: 1
|
||||
forumTopicId: 301639
|
||||
dashedName: delete-a-node-with-two-children-in-a-binary-search-tree
|
||||
@ -8,15 +8,15 @@ dashedName: delete-a-node-with-two-children-in-a-binary-search-tree
|
||||
|
||||
# --description--
|
||||
|
||||
Removing nodes that have two children is the hardest case to implement. Removing a node like this produces two subtrees that are no longer connected to the original tree structure. How can we reconnect them? One method is to find the smallest value in the right subtree of the target node and replace the target node with this value. Selecting the replacement in this way ensures that it is greater than every node in the left subtree it becomes the new parent of but also less than every node in the right subtree it becomes the new parent of. Once this replacement is made the replacement node must be removed from the right subtree. Even this operation is tricky because the replacement may be a leaf or it may itself be the parent of a right subtree. If it is a leaf we must remove its parent's reference to it. Otherwise, it must be the right child of the target. In this case, we must replace the target value with the replacement value and make the target reference the replacement's right child.
|
||||
Rimuovere i nodi che hanno due figli è il caso più difficile da implementare. Rimuovere un nodo come questo produce due sotto-alberi che non sono più collegati alla struttura originale dell'albero. Come possiamo ricollegarli? Un metodo è quello di trovare il valore più piccolo nel sottoalbero destro del nodo obiettivo e sostituire il nodo obiettivo con questo valore. Selezionare il rimpiazzo in questo modo assicura che sia maggiore di ogni nodo nel sottoalbero sinistro di cui diventa il nuovo genitore ma anche minore di ogni nodo nel sottoalbero destro di cui diventa il nuovo genitore. Una volta effettuata la sostituzione, il nodo di rimpiazzo deve essere rimosso dal sotto-albero destro. Anche questa operazione è difficile perché il rimpiazzo può essere una foglia o può essere di per sé il genitore di un sottoalbero destro. Se si tratta di una foglia dobbiamo eliminare il riferimento nel suo genitore. In caso contrario, deve essere il figlio destro del nodo obiettivo. In questo caso, dobbiamo sostituire il valore obiettivo con il valore di sostituzione e far sì che il riferimento dell'obiettivo punti al figlio destro del sostituto.
|
||||
|
||||
# --instructions--
|
||||
|
||||
Let's finish our `remove` method by handling the third case. We've provided some code again for the first two cases. Add some code now to handle target nodes with two children. Any edge cases to be aware of? What if the tree has only three nodes? Once you are finished this will complete our deletion operation for binary search trees. Nice job, this is a pretty hard problem!
|
||||
Finiamo il nostro metodo `remove` gestendo il terzo caso. Abbiamo fornito di nuovo del codice per i primi due casi. Aggiungi adesso un po' di codice per gestire i nodi obiettivo con due figli. Eventuali casi limite di cui essere a conoscenza? E se l'albero avesse solo tre nodi? Una volta finito, questo completerà la nostra operazione di cancellazione per gli alberi di ricerca binari. Bel lavoro, questo è un problema piuttosto difficile!
|
||||
|
||||
# --hints--
|
||||
|
||||
The `BinarySearchTree` data structure should exist.
|
||||
La struttura di dati `BinarySearchTree` dovrebbe esistere.
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -30,7 +30,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
The binary search tree should have a method called `remove`.
|
||||
L'albero binario di ricerca dovrebbe avere un metodo chiamato `remove`.
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -46,7 +46,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
Trying to remove an element that does not exist should return `null`.
|
||||
Tentare di rimuovere un elemento che non esiste dovrebbe restituire `null`.
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -62,7 +62,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
If the root node has no children, deleting it should set the root to `null`.
|
||||
Se il nodo radice non ha figli, l'eliminazione dovrebbe impostare la radice a `null`.
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -80,7 +80,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
The `remove` method should remove leaf nodes from the tree.
|
||||
Il metodo `remove` dovrebbe rimuovere i nodi foglia dall'albero.
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -107,7 +107,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
The `remove` method should remove nodes with one child.
|
||||
Il metodo `remove` dovrebbe rimuovere i nodi con un figlio.
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -133,7 +133,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
Removing the root in a tree with two nodes should set the second to be the root.
|
||||
Rimuovere la radice in un albero con due nodi dovrebbe impostare il secondo come radice.
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -155,7 +155,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
The `remove` method should remove nodes with two children while maintaining the binary search tree structure.
|
||||
Il metodo `remove` dovrebbe rimuovere i nodi con due figli mantenendo la struttura dell'albero binario di ricerca.
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -212,7 +212,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
The root should be removable on a tree of three nodes.
|
||||
La radice dovrebbe essere rimovibile su un albero di tre nodi.
|
||||
|
||||
```js
|
||||
assert(
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d825d367417b2b2512c96
|
||||
title: Depth-First Search
|
||||
title: Ricerca Depth-First
|
||||
challengeType: 1
|
||||
forumTopicId: 301640
|
||||
dashedName: depth-first-search
|
||||
@ -8,31 +8,31 @@ dashedName: depth-first-search
|
||||
|
||||
# --description--
|
||||
|
||||
Similar to <dfn>breadth-first search</dfn>, here we will learn about another graph traversal algorithm called <dfn>depth-first search</dfn>.
|
||||
Similmente alla ricerca <dfn>breadth-first</dfn>, qui impareremo a conoscere un altro algoritmo di attraversamento chiamato ricerca <dfn>depth-first</dfn>.
|
||||
|
||||
Whereas the breadth-first search searches incremental edge lengths away from the source node, <dfn>depth-first search</dfn> first goes down a path of edges as far as it can.
|
||||
Mentre la ricerca breadth-first cerca lunghezze di archi incrementali lontano dal nodo di origine, la ricerca <dfn>depth-first</dfn> scende prima lungo un percorso di archi il più profondo possibile.
|
||||
|
||||
Once it reaches one end of a path, the search will backtrack to the last node with an un-visited edge path and continue searching.
|
||||
Una volta che raggiunge la fine di un percorso, la ricerca tornerà indietro fino all'ultimo nodo con un percorso di archi non visitato e continuerà a cercare.
|
||||
|
||||
The animation below shows how the algorithm works. The algorithm starts with the top node and visits the nodes in the numbered order.
|
||||
L'animazione qui sotto mostra come funziona l'algoritmo. L'algoritmo inizia con il nodo iniziale e visita i nodi nell'ordine numerato.
|
||||
|
||||
<img class='img-responsive' src='https://camo.githubusercontent.com/aaad9e39961daf34d967c616edeb50abf3bf1235/68747470733a2f2f75706c6f61642e77696b696d656469612e6f72672f77696b6970656469612f636f6d6d6f6e732f372f37662f44657074682d46697273742d5365617263682e676966' />
|
||||
|
||||
Notice how, unlike breadth-first search, every time a node is visited, it doesn't visit all of its neighbors. Instead, it first visits one of its neighbors and continues down that path until there are no more nodes to be visited on that path.
|
||||
Nota come, a differenza della ricerca breadth-first, ogni volta che un nodo viene visitato, non visita tutti i suoi vicini. Invece, prima visita uno dei suoi vicini e continua lungo quel percorso fino a quando non ci sono più nodi da visitare su di esso.
|
||||
|
||||
To implement this algorithm, you'll want to use a stack. A stack is an array where the last element added is the first to be removed. This is also known as a <dfn>Last-In-First-Out</dfn> data structure. A stack is helpful in depth-first search algorithms because, as we add neighbors to the stack, we want to visit the most recently added neighbors first and remove them from the stack.
|
||||
Per implementare questo algoritmo, vorrai utilizzare una pila (stack). Una pila è un array in cui l'ultimo elemento aggiunto è il primo ad essere rimosso. Questo è noto anche come una struttura di dati <dfn>Last-In-First-Out</dfn>. Uno stack è utile negli algoritmi di ricerca depth-first perché, mano a mano che aggiungiamo nodi vicini allo stack, vogliamo visitare prima i nodi vicini aggiunti più di recente e rimuoverli dallo stack.
|
||||
|
||||
A simple output of this algorithm is a list of nodes which are reachable from a given node. Therefore, you'll also want to keep track of the nodes you visit.
|
||||
Un semplice output di questo algoritmo è un elenco di nodi raggiungibili da un dato nodo. Pertanto, dovrai anche tenere traccia dei nodi che visiti.
|
||||
|
||||
# --instructions--
|
||||
|
||||
Write a function `dfs()` that takes an undirected, adjacency matrix `graph` and a node label `root` as parameters. The node label will just be the numeric value of the node between `0` and `n - 1`, where `n` is the total number of nodes in the graph.
|
||||
Scrivi una funzione `dfs()` che richiede una matrice di adiacenza non orientata `graph`, e un'etichetta di nodo `root` come parametri. L' etichetta del nodo sarà solo il valore numerico del nodo tra `0` e `n - 1`, dove `n` è il numero totale dei nodi nel grafo.
|
||||
|
||||
Your function should output an array of all nodes reachable from `root`.
|
||||
La tua funzione dovrebbe generare un array di tutti i nodi raggiungibili da `root`.
|
||||
|
||||
# --hints--
|
||||
|
||||
The input graph `[[0, 1, 0, 0], [1, 0, 1, 0], [0, 1, 0, 1], [0, 0, 1, 0]]` with a start node of `1` should return an array with `0`, `1`, `2`, and `3`.
|
||||
Il grafo di input `[[0, 1, 0, 0], [1, 0, 1, 0], [0, 1, 0, 1], [0, 0, 1, 0]]` con un nodo iniziale di `1` dovrebbe restituire un array con `0`, `1`, `2`e `3`.
|
||||
|
||||
```js
|
||||
assert.sameMembers(
|
||||
@ -49,7 +49,7 @@ assert.sameMembers(
|
||||
);
|
||||
```
|
||||
|
||||
The input graph `[[0, 1, 0, 0], [1, 0, 1, 0], [0, 1, 0, 1], [0, 0, 1, 0]]` with a start node of `1` should return an array with four elements.
|
||||
Il grafo di input `[[0, 1, 0, 0], [1, 0, 1, 0], [0, 1, 0, 1], [0, 0, 1, 0]]` con un nodo di partenza di `1` dovrebbe restituire un array con quattro elementi.
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -65,7 +65,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
The input graph `[[0, 1, 0, 0], [1, 0, 1, 0], [0, 1, 0, 0], [0, 0, 0, 0]]` with a start node of `3` should return an array with `3`.
|
||||
Il grafo di input `[[0, 1, 0, 0], [1, 0, 1, 0], [0, 1, 0, 0], [0, 0, 0, 0]]` con un nodo di partenza di `3` dovrebbe restituire un array con `3`.
|
||||
|
||||
```js
|
||||
assert.sameMembers(
|
||||
@ -82,7 +82,7 @@ assert.sameMembers(
|
||||
);
|
||||
```
|
||||
|
||||
The input graph `[[0, 1, 0, 0], [1, 0, 1, 0], [0, 1, 0, 0], [0, 0, 0, 0]]` with a start node of `3` should return an array with one element.
|
||||
Il grafo di input `[[0, 1, 0, 0], [1, 0, 1, 0], [0, 1, 0, 0], [0, 0, 0, 0]]` con un nodo iniziale di `3` dovrebbe restituire un array con un unico elemento.
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -98,7 +98,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
The input graph `[[0, 1, 0, 0], [1, 0, 0, 0], [0, 0, 0, 1], [0, 0, 1, 0]]` with a start node of `3` should return an array with `2` and `3`.
|
||||
Il grafo di input `[[0, 1, 0, 0], [1, 0, 0, 0], [0, 0, 0, 1], [0, 0, 1, 0]]` con un nodo iniziale di `3` dovrebbe restituire un array con `2` e `3`.
|
||||
|
||||
```js
|
||||
assert.sameMembers(
|
||||
@ -115,7 +115,7 @@ assert.sameMembers(
|
||||
);
|
||||
```
|
||||
|
||||
The input graph `[[0, 1, 0, 0], [1, 0, 0, 0], [0, 0, 0, 1], [0, 0, 1, 0]]` with a start node of `3` should return an array with two elements.
|
||||
Il grafo di input `[[0, 1, 0, 0], [1, 0, 0, 0], [0, 0, 0, 1], [0, 0, 1, 0]]` con un nodo di inizio di `3` dovrebbe restituire un array con due elementi.
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -131,7 +131,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
The input graph `[[0, 1, 0, 0], [1, 0, 0, 0], [0, 0, 0, 1], [0, 0, 1, 0]]` with a start node of `0` should return an array with `0` and `1`.
|
||||
Il grafo di input `[[0, 1, 0, 0], [1, 0, 0, 0], [0, 0, 0, 1], [0, 0, 1, 0]]` con un nodo iniziale di `0` deve restituire un array con `0` e `1`.
|
||||
|
||||
```js
|
||||
assert.sameMembers(
|
||||
@ -148,7 +148,7 @@ assert.sameMembers(
|
||||
);
|
||||
```
|
||||
|
||||
The input graph `[[0, 1, 0, 0], [1, 0, 0, 0], [0, 0, 0, 1], [0, 0, 1, 0]]` with a start node of `0` should return an array with two elements.
|
||||
Il grafo di input `[[0, 1, 0, 0], [1, 0, 0, 0], [0, 0, 0, 1], [0, 0, 1, 0]]` con un nodo di inizio di `0` dovrebbe restituire un array con due elementi.
|
||||
|
||||
```js
|
||||
assert(
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d8250367417b2b2512c5e
|
||||
title: Learn how a Stack Works
|
||||
title: Impara come funziona uno stack
|
||||
challengeType: 1
|
||||
forumTopicId: 301705
|
||||
dashedName: learn-how-a-stack-works
|
||||
@ -8,43 +8,43 @@ dashedName: learn-how-a-stack-works
|
||||
|
||||
# --description--
|
||||
|
||||
You are probably familiar with stack of books on your table. You have likely used the undo feature of a text editor. You are also probably used to hitting the back button on your phone to go back to the previous view in your app.
|
||||
Probabilmente hai familiarità con la pila di libri sul tuo tavolo. Probabilmente hai usato la funzione di annullamento di un editor di testo. Probabilmente sei anche abituato a premere il pulsante indietro sul telefono per tornare alla vista precedente nella tua app.
|
||||
|
||||
You know what they all have in common? They all store the data in a way so that you can traverse backwards.
|
||||
Sai cos'hanno in comune queste cose? Tutte memorizzano i dati in modo che possano essere ripercorsi all'indietro.
|
||||
|
||||
The topmost book in the stack was the one that was put there last. If you remove that book from your stack's top, you would expose the book that was put there before the last book and so on.
|
||||
Il libro più in alto nella pila è quello che era stato messo lì per ultimo. Se si rimuove quel libro dalla cima della pila, si espone il libro che è stato messo lì prima dell'ultimo e così via.
|
||||
|
||||
If you think about it, in all the above examples, you are getting <dfn>Last-In-First-Out</dfn> type of service. We will try to mimic this with our code.
|
||||
Se ci pensi, in tutti gli esempi di cui sopra, si sta ottenendo il tipo di servizio <dfn>Last-In-First-Out</dfn>. Cercheremo di imitarlo con il nostro codice.
|
||||
|
||||
This data storage scheme is called a <dfn>Stack</dfn>. In particular, we would have to implement the `push()` method that pushes JavaScript objects at the top of the stack; and `pop()` method, that removes the JavaScript object that's at the top of the stack at the current moment.
|
||||
Questo schema di memorizzazione dati è chiamato <dfn>Stack</dfn> (pila). In particolare, dovremmo implementare il metodo `push()` che inserisce gli oggetti JavaScript nella parte superiore della pila; e il metodo `pop()`, che rimuove l'oggetto JavaScript in cima ad essa al momento attuale.
|
||||
|
||||
# --instructions--
|
||||
|
||||
Here we have a stack of homework assignments represented as an array: `"BIO12"` is at the base, and `"PSY44"` is at the top of the stack.
|
||||
Qui abbiamo una pila di compiti a casa rappresentati come un array: `"BIO12"` è alla base dello stack, e `"PSY44"` è in cima.
|
||||
|
||||
Modify the given array and treat it like a `stack` using the JavaScript methods mentioned above. Remove the top element `"PSY44"` from the stack. Then add `"CS50"` to be the new top element of the stack.
|
||||
Modifica l'array dato e trattarlo come uno `stack` utilizzando i metodi JavaScript sopra menzionati. Rimuovi l'elemento superiore `"PSY44"` dallo stack. Quindi aggiungi `"CS50"` in modo che sia il nuovo elemento in cima allo stack.
|
||||
|
||||
# --hints--
|
||||
|
||||
`homeworkStack` should only contain 4 elements.
|
||||
`homeworkStack` dovrebbe contenere solo 4 elementi.
|
||||
|
||||
```js
|
||||
assert(homeworkStack.length === 4);
|
||||
```
|
||||
|
||||
The last element in `homeworkStack` should be `"CS50"`.
|
||||
L'ultimo elemento in `homeworkStack` dovrebbe essere `"CS50"`.
|
||||
|
||||
```js
|
||||
assert(homeworkStack[3] === 'CS50');
|
||||
```
|
||||
|
||||
`homeworkStack` should not contain `"PSY44"`.
|
||||
`homeworkStack` non dovrebbe contenere `"PSY44"`.
|
||||
|
||||
```js
|
||||
assert(homeworkStack.indexOf('PSY44') === -1);
|
||||
```
|
||||
|
||||
The initial declaration of the `homeworkStack` should not be changed.
|
||||
La dichiarazione iniziale di `homeworkStack` non dovrebbe essere modificata.
|
||||
|
||||
```js
|
||||
assert(
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d8254367417b2b2512c6e
|
||||
title: Perform a Difference on Two Sets of Data
|
||||
title: Eseguire una differenza su due insiemi di dati
|
||||
challengeType: 1
|
||||
forumTopicId: 301706
|
||||
dashedName: perform-a-difference-on-two-sets-of-data
|
||||
@ -8,13 +8,13 @@ dashedName: perform-a-difference-on-two-sets-of-data
|
||||
|
||||
# --description--
|
||||
|
||||
In this exercise we are going to perform a difference on 2 sets of data. We will create a method on our `Set` data structure called `difference`. A difference of sets should compare two sets and return the items present in the first set that are absent in the second. This method should take another `Set` as an argument and return the `difference` of the two sets.
|
||||
In questo esercizio eseguiremo una differenza su 2 set di dati. Creeremo un metodo sulla nostra struttura di dati `Set` chiamato `difference`. Una differenza di insiemi dovrebbe confrontare due insiemi e restituire gli elementi presenti nel primo insieme che sono assenti nel secondo. Questo metodo dovrebbe prendere un altro `Set` come argomento e restituire la `difference` dei due set.
|
||||
|
||||
For example, if `setA = ['a','b','c']` and `setB = ['a','b','d','e']`, then the difference of setA and setB is: `setA.difference(setB) = ['c']`.
|
||||
Per esempio, se `setA = ['a','b','c']` e `setB = ['a','b','d','e']`, allora la differenza di setA e setB è: `setA.difference(setB) = ['c']`.
|
||||
|
||||
# --hints--
|
||||
|
||||
Your `Set` class should have a `difference` method.
|
||||
La tua classe `Set` dovrebbe avere un metodo `difference`.
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -25,7 +25,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
Your `difference` method should return the proper collection.
|
||||
Il metodo `difference` dovrebbe restituire la collezione corretta.
|
||||
|
||||
```js
|
||||
assert(
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 5949b579404977fbaefcd736
|
||||
title: 9 billion names of God the integer
|
||||
title: I 9 miliardi di nomi di Dio
|
||||
challengeType: 5
|
||||
forumTopicId: 302219
|
||||
dashedName: 9-billion-names-of-god-the-integer
|
||||
@ -8,21 +8,21 @@ dashedName: 9-billion-names-of-god-the-integer
|
||||
|
||||
# --description--
|
||||
|
||||
This task is a variation of the [short story by Arthur C. Clarke](https://en.wikipedia.org/wiki/The Nine Billion Names of God#Plot_summary "wp: The Nine Billion Names of God#Plot_summary").
|
||||
Questa sfida è una variazione [della storia breve di Arthur C. Clarke](https://it.wikipedia.org/wiki/I_nove_miliardi_di_nomi_di_Dio).
|
||||
|
||||
(Solvers should be aware of the consequences of completing this task.)
|
||||
(I risolutori dovrebbero essere consapevoli delle consequenze di completare questa sfida)
|
||||
|
||||
In detail, to specify what is meant by a "name":
|
||||
In dettaglio, per specificare cosa si intende per "nome":
|
||||
|
||||
<ul>
|
||||
<li>The integer 1 has 1 name "1".</li>
|
||||
<li>The integer 2 has 2 names "1+1" and "2".</li>
|
||||
<li>The integer 3 has 3 names "1+1+1", "2+1", and "3".</li>
|
||||
<li>The integer 4 has 5 names "1+1+1+1", "2+1+1", "2+2", "3+1", "4".</li>
|
||||
<li>The integer 5 has 7 names "1+1+1+1+1", "2+1+1+1", "2+2+1", "3+1+1", "3+2", "4+1", "5".</li>
|
||||
<li>Il numero 1 ha 1 nome "1".</li>
|
||||
<li>Il numero 2 ha 2 nomi "1+1" e "2".</li>
|
||||
<li>Il numero 3 ha 3 nomi "1+1+1", "2+1", e "3".</li>
|
||||
<li>Il numero 4 ha 5 nomi "1+1+1+1", "2+1+1", "2+2", "3+1" e "4".</li>
|
||||
<li>Il numero 5 ha 7 nomi "1+1+1+1+1", "2+1+1+1", "2+2+1", "3+1+1", "3+2", "4+1", "5".</li>
|
||||
</ul>
|
||||
|
||||
This can be visualized in the following form:
|
||||
Questo può essere visualizzato nella seguente forma:
|
||||
|
||||
<pre> 1
|
||||
1 1
|
||||
@ -32,53 +32,53 @@ This can be visualized in the following form:
|
||||
1 3 3 2 1 1
|
||||
</pre>
|
||||
|
||||
Where row $n$ corresponds to integer $n$, and each column $C$ in row $m$ from left to right corresponds to the number of names beginning with $C$.
|
||||
Dove la riga $n$ corrisponde al numero $n$, e ogni colonna $C$ nella riga $m$ da sinistra a destra corrisponde al numero di nomi che inizia con $C$.
|
||||
|
||||
Optionally note that the sum of the $n$-th row $P(n)$ is the integer partition function.
|
||||
Facoltativamente, nota che la somma dell'$n$-sima riga $P(n)$ è la funzione di partizione dei numeri interi.
|
||||
|
||||
# --instructions--
|
||||
|
||||
Implement a function that returns the sum of the $n$-th row.
|
||||
Implementa una funzione che restituisca la somma della $n$-sima riga.
|
||||
|
||||
# --hints--
|
||||
|
||||
`numberOfNames` should be function.
|
||||
`numberOfNames` dovrebbe essere una funzione.
|
||||
|
||||
```js
|
||||
assert(typeof numberOfNames === 'function');
|
||||
```
|
||||
|
||||
`numberOfNames(5)` should equal 7.
|
||||
`numberOfNames(5)` dovrebbe essere uguale a 7.
|
||||
|
||||
```js
|
||||
assert.equal(numberOfNames(5), 7);
|
||||
```
|
||||
|
||||
`numberOfNames(12)` should equal 77.
|
||||
`numberOfNames(12)` dovrebbe essere uguale a 77.
|
||||
|
||||
```js
|
||||
assert.equal(numberOfNames(12), 77);
|
||||
```
|
||||
|
||||
`numberOfNames(18)` should equal 385.
|
||||
`numberOfNames(18)` dovrebbe essere uguale a 385.
|
||||
|
||||
```js
|
||||
assert.equal(numberOfNames(18), 385);
|
||||
```
|
||||
|
||||
`numberOfNames(23)` should equal 1255.
|
||||
`numberOfNames(23)` dovrebbe essere uguale a 1255.
|
||||
|
||||
```js
|
||||
assert.equal(numberOfNames(23), 1255);
|
||||
```
|
||||
|
||||
`numberOfNames(42)` should equal 53174.
|
||||
`numberOfNames(42)` dovrebbe essere uguale a 53174.
|
||||
|
||||
```js
|
||||
assert.equal(numberOfNames(42), 53174);
|
||||
```
|
||||
|
||||
`numberOfNames(123)` should equal 2552338241.
|
||||
`numberOfNames(123)` dovrebbe essere uguale a 2552338241.
|
||||
|
||||
```js
|
||||
assert.equal(numberOfNames(123), 2552338241);
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 594810f028c0303b75339acc
|
||||
title: ABC Problem
|
||||
title: Problema ABC
|
||||
challengeType: 5
|
||||
forumTopicId: 302220
|
||||
dashedName: abc-problem
|
||||
@ -8,7 +8,7 @@ dashedName: abc-problem
|
||||
|
||||
# --description--
|
||||
|
||||
You are given a collection of ABC blocks (e.g., childhood alphabet blocks). There are 20 blocks with two letters on each block. A complete alphabet is guaranteed amongst all sides of the blocks. The sample collection of blocks:
|
||||
Ti viene data una collezione di blocchi ABC (tipo i cubi con le lettere per i bambini). Ci sono 20 blocchi con due lettere su ogni blocco. Considerando tutti i lati dei blocchi è garantito un alfabeto completo. Ecco un esempio di una collezione di blocchi:
|
||||
|
||||
<pre>(B O)
|
||||
(X K)
|
||||
@ -34,60 +34,60 @@ You are given a collection of ABC blocks (e.g., childhood alphabet blocks). Ther
|
||||
|
||||
# --instructions--
|
||||
|
||||
Implement a function that takes a string (word) and determines whether the word can be spelled with the given collection of blocks.
|
||||
Implementa una funzione che prende una stringa (parola) e determina se la parola può essere scritta con la collezione di blocchi data.
|
||||
|
||||
Some rules to keep in mind:
|
||||
Alcune regole da tenere a mente:
|
||||
|
||||
<ul>
|
||||
<li>Once a letter on a block is used, that block cannot be used again.</li>
|
||||
<li>The function should be case-insensitive.</li>
|
||||
<li>Una volta che viene utilizzata una lettera su un blocco, quel blocco non può essere usato di nuovo.</li>
|
||||
<li>La funzione non deve fare distinzione tra maiuscole e minuscole.</li>
|
||||
</ul>
|
||||
|
||||
# --hints--
|
||||
|
||||
`canMakeWord` should be a function.
|
||||
`canMakeWord` dovrebbe essere una funzione.
|
||||
|
||||
```js
|
||||
assert(typeof canMakeWord === 'function');
|
||||
```
|
||||
|
||||
`canMakeWord` should return a boolean.
|
||||
`canMakeWord` dovrebbe restituire un valore booleano.
|
||||
|
||||
```js
|
||||
assert(typeof canMakeWord('hi') === 'boolean');
|
||||
```
|
||||
|
||||
`canMakeWord("bark")` should return true.
|
||||
`canMakeWord("bark")` dovrebbe restituire true.
|
||||
|
||||
```js
|
||||
assert(canMakeWord(words[0]));
|
||||
```
|
||||
|
||||
`canMakeWord("BooK")` should return false.
|
||||
`canMakeWord("BooK")` dovrebbe restituire false.
|
||||
|
||||
```js
|
||||
assert(!canMakeWord(words[1]));
|
||||
```
|
||||
|
||||
`canMakeWord("TReAT")` should return true.
|
||||
`canMakeWord("TReAT")` dovrebbe restituire true.
|
||||
|
||||
```js
|
||||
assert(canMakeWord(words[2]));
|
||||
```
|
||||
|
||||
`canMakeWord("COMMON")` should return false.
|
||||
`canMakeWord("COMMON")` dovrebbe restituire false.
|
||||
|
||||
```js
|
||||
assert(!canMakeWord(words[3]));
|
||||
```
|
||||
|
||||
`canMakeWord("squAD")` should return true.
|
||||
`canMakeWord("squAD")` dovrebbe restituire true.
|
||||
|
||||
```js
|
||||
assert(canMakeWord(words[4]));
|
||||
```
|
||||
|
||||
`canMakeWord("conFUSE")` should return true.
|
||||
`canMakeWord("conFUSE")` dovrebbe restituire false.
|
||||
|
||||
```js
|
||||
assert(canMakeWord(words[5]));
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 594810f028c0303b75339acd
|
||||
title: 'Abundant, deficient and perfect number classifications'
|
||||
title: 'Classificazione dei numeri abbondanti, carenti e perfetti'
|
||||
challengeType: 5
|
||||
forumTopicId: 302221
|
||||
dashedName: abundant-deficient-and-perfect-number-classifications
|
||||
@ -8,55 +8,55 @@ dashedName: abundant-deficient-and-perfect-number-classifications
|
||||
|
||||
# --description--
|
||||
|
||||
These define three classifications of positive integers based on their proper divisors.
|
||||
Queste definiscono tre classificazioni di numeri interi positivi basate sui loro divisori.
|
||||
|
||||
Let $P(n)$ be the sum of the proper divisors of `n` where proper divisors are all positive integers `n` other than `n` itself.
|
||||
Sia $P(n)$ la somma dei divisori di `n` dove i divisori sono tutti interi positivi `n` diversi da `n` stesso.
|
||||
|
||||
If `P(n) < n` then `n` is classed as `deficient`
|
||||
Se `P(n) < n` allora `n` è classificato come `deficient`
|
||||
|
||||
If `P(n) === n` then `n` is classed as `perfect`
|
||||
Se `P(n) === n` allora `n` è classificato come `perfect`
|
||||
|
||||
If `P(n) > n` then `n` is classed as `abundant`
|
||||
Se `P(n) > n` allora `n` è classificato come `abundant`
|
||||
|
||||
**Example**: `6` has proper divisors of `1`, `2`, and `3`. `1 + 2 + 3 = 6`, so `6` is classed as a perfect number.
|
||||
**Esempio**: `6` ha i divisori `1`, `2` e `3`. `1 + 2 + 3 = 6`, quindi `6` è classificato come numero perfetto.
|
||||
|
||||
# --instructions--
|
||||
|
||||
Implement a function that calculates how many of the integers from `1` to `num` (inclusive) are in each of the three classes. Output the result as an array in the following format `[deficient, perfect, abundant]`.
|
||||
Implementa una funzione che calcola quanti numeri interi tra `1` e `num` (inclusi) sono in queste tre categorie. Restituisci il risultato come un array nel seguente formato `[deficient, perfect, abundant]`.
|
||||
|
||||
# --hints--
|
||||
|
||||
`getDPA` should be a function.
|
||||
`getDPA` dovrebbe essere una funzione.
|
||||
|
||||
```js
|
||||
assert(typeof getDPA === 'function');
|
||||
```
|
||||
|
||||
`getDPA(5000)` should return an array.
|
||||
`getDPA(5000)` dovrebbe restituire un array.
|
||||
|
||||
```js
|
||||
assert(Array.isArray(getDPA(5000)));
|
||||
```
|
||||
|
||||
`getDPA(5000)` return array should have a length of `3`.
|
||||
`getDPA(5000)` dovrebbe restituire un array di lunghezza `3`.
|
||||
|
||||
```js
|
||||
assert(getDPA(5000).length === 3);
|
||||
```
|
||||
|
||||
`getDPA(5000)` should return `[3758, 3, 1239]`.
|
||||
`getDPA(5000)` dovrebbe restituire `[3758, 3, 1239]`.
|
||||
|
||||
```js
|
||||
assert.deepEqual(getDPA(5000), [3758, 3, 1239]);
|
||||
```
|
||||
|
||||
`getDPA(10000)` should return `[7508, 4, 2488]`.
|
||||
`getDPA(10000)` dovrebbe restituire `[7508, 4, 2488]`.
|
||||
|
||||
```js
|
||||
assert.deepEqual(getDPA(10000), [7508, 4, 2488]);
|
||||
```
|
||||
|
||||
`getDPA(20000)` should return `[15043, 4, 4953]`.
|
||||
`getDPA(20000)` dovrebbe restituire `[15043, 4, 4953]`.
|
||||
|
||||
```js
|
||||
assert.deepEqual(getDPA(20000), [15043, 4, 4953]);
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: bd7158d8c443eddfaeb5bdee
|
||||
title: Build a Pinterest Clone
|
||||
title: Costruisci un Clone di Pinterest
|
||||
challengeType: 4
|
||||
forumTopicId: 302352
|
||||
dashedName: build-a-pinterest-clone
|
||||
@ -8,27 +8,27 @@ dashedName: build-a-pinterest-clone
|
||||
|
||||
# --description--
|
||||
|
||||
**Objective:** Build a [Replit](https://replit.com/) app that is functionally similar to this: <https://build-a-pinterest-clone.freecodecamp.rocks/>.
|
||||
**Obiettivo:** Costruisci un'app [Replit](https://replit.com/) funzionalmente simile a questa: [https://p2phttps://build-a-pinterest-clone.freecodecamp.rocks/](https://build-a-pinterest-clone.freecodecamp.rocks/).
|
||||
|
||||
Fulfill the below [user stories](https://en.wikipedia.org/wiki/User_story). Use whichever libraries or APIs you need. Give it your own personal style.
|
||||
Soddisfa le seguenti [user story](https://en.wikipedia.org/wiki/User_story). Utilizza le librerie o le API di cui hai bisogno. Usa il tuo stile personale.
|
||||
|
||||
**User Story:** As an unauthenticated user, I can login with GitHub.
|
||||
**User Story:** Come utente non autenticato, posso autenticarmi con GitHub.
|
||||
|
||||
**User Story:** As an authenticated user, I can link to images.
|
||||
**User Story:** Come utente autenticato, posso linkare a immagini.
|
||||
|
||||
**User Story:** As an authenticated user, I can delete images that I've linked to.
|
||||
**User Story:** Come utente autenticato, posso eliminare immagini che ho linkato.
|
||||
|
||||
**User Story:** As an authenticated user, I can see a Pinterest-style wall of all the images I've linked to.
|
||||
**User Story:** Come utente autenticato, posso vedere un muro di immagini che ho linkato nello stile di Pinterest.
|
||||
|
||||
**User Story:** As an unauthenticated user, I can browse other users' walls of images.
|
||||
**User Story:** Come utente non autenticato, posso navigare i muri di immagini degli altri utenti.
|
||||
|
||||
**User Story:** As an authenticated user, if I upload an image that is broken, it will be replaced by a placeholder image. (can use jQuery broken image detection)
|
||||
**User Story:** Come utente autenticato, se carico una immagine rotta, sarà rimpiazzata da una immagine segnaposto. (puoi usare il rilevatore di immagini rotte di jQuery)
|
||||
|
||||
**Hint:** [Masonry.js](https://masonry.desandro.com/) is a library that allows for Pinterest-style image grids.
|
||||
**Suggerimento:** [Masonry.js](https://masonry.desandro.com/) è una libreria che permette griglie di immagini nello stile di Pinterest.
|
||||
|
||||
Once you've finished implementing these user stories, enter the URL to your live app and, optionally, your GitHub repository. Then click the "I've completed this challenge" button.
|
||||
Una volta terminata l'implementazione di queste user story, scrivi l'URL della tua app live e, opzionalmente, il tuo repository GitHub. Quindi clicca sul pulsante "Ho completato questa sfida".
|
||||
|
||||
You can get feedback on your project by sharing it on the [freeCodeCamp forum](https://forum.freecodecamp.org/c/project-feedback/409).
|
||||
Puoi ottenere un feedback sul tuo progetto condividendolo sul forum [freeCodeCamp](https://forum.freecodecamp.org/c/project-feedback/409).
|
||||
|
||||
# --solutions--
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: bd7158d8c442eddfaeb5bd1c
|
||||
title: Build a Simon Game
|
||||
title: Costruisci un gioco Simon
|
||||
challengeType: 3
|
||||
forumTopicId: 302357
|
||||
dashedName: build-a-simon-game
|
||||
@ -8,31 +8,31 @@ dashedName: build-a-simon-game
|
||||
|
||||
# --description--
|
||||
|
||||
**Objective:** Build a [CodePen.io](https://codepen.io) app that is functionally similar to this: [https://codepen.io/freeCodeCamp/full/obYBjE](https://codepen.io/freeCodeCamp/full/obYBjE).
|
||||
**Obiettivo:** Costruisci un'app [CodePen.io](https://codepen.io) funzionalmente simile a questa: [https://codepen.io/freeCodeCamp/full/obYBjE](https://codepen.io/freeCodeCamp/full/obYBjE).
|
||||
|
||||
Fulfill the below [user stories](https://en.wikipedia.org/wiki/User_story). Use whichever libraries or APIs you need. Give it your own personal style.
|
||||
Soddisfa le seguenti [user story](https://en.wikipedia.org/wiki/User_story). Utilizza le librerie o le API di cui hai bisogno. Usa il tuo stile personale.
|
||||
|
||||
**User Story:** I am presented with a random series of button presses.
|
||||
**User Story:** Mi viene presentata una serie casuale di pressione dei bottoni.
|
||||
|
||||
**User Story:** Each time I input a series of button presses correctly, I see the same series of button presses but with an additional step.
|
||||
**User Story:** Ogni volta che inserisco correttamente una serie di pressione di bottoni, vedo la stessa serie ma con uno step in più.
|
||||
|
||||
**User Story:** I hear a sound that corresponds to each button both when the series of button presses plays, and when I personally press a button.
|
||||
**User Story:** Sento un suono che corrisponde a ogni bottone sia quando la serie di bottoni è premuta automaticamente, sia quando personalmente premo un bottone.
|
||||
|
||||
**User Story:** If I press the wrong button, I am notified that I have done so, and that series of button presses starts again to remind me of the pattern so I can try again.
|
||||
**User Story:** Se premo il pulsante sbagliato mi viene detto, e la serie di pressioni dei bottoni ricomincia di nuovo in modo da ricordarmi quale è la serie corretta e possa provare di nuovo.
|
||||
|
||||
**User Story:** I can see how many steps are in the current series of button presses.
|
||||
**User Story:** Posso vedere quanti step ci sono nella serie attuale di pulsanti.
|
||||
|
||||
**User Story:** If I want to restart, I can hit a button to do so, and the game will return to a single step.
|
||||
**User Story:** Se voglio ricominciare, posso premere un bottone per farlo, e il gioco ritornerà a una serie con uno step solo.
|
||||
|
||||
**User Story:** I can play in strict mode where if I get a button press wrong, it notifies me that I have done so, and the game restarts at a new random series of button presses.
|
||||
**User Story:** Posso giocare in modalità severa dove se premo il pulsante sbagliato, mi dice che ho sbagliato, e il gioco ricomincia con una nuova serie casuale di pulsanti.
|
||||
|
||||
**User Story:** I can win the game by getting a series of 20 steps correct. I am notified of my victory, then the game starts over.
|
||||
**User Story:** Posso vincere il gioco inserendo correttamnete una serie di 20 step. Vengo informato della mia vittoria, poi il gioco ricomincia da capo.
|
||||
|
||||
**Hint:** Here are mp3s you can use for each button: `https://s3.amazonaws.com/freecodecamp/simonSound1.mp3`, `https://s3.amazonaws.com/freecodecamp/simonSound2.mp3`, `https://s3.amazonaws.com/freecodecamp/simonSound3.mp3`, `https://s3.amazonaws.com/freecodecamp/simonSound4.mp3`.
|
||||
**Suggerimento:** Ecco degli mp3s che puoi usare per ogni pulsante: `https://s3.amazonaws.com/freecodecamp/simonSound1.mp3`, `https://s3.amazonaws.com/freecodecamp/simonSound2.mp3`, `https://s3.amazonaws.com/freecodecamp/simonSound3.mp3`, `https://s3.amazonaws.com/freecodecamp/simonSound4.mp3`.
|
||||
|
||||
When you are finished, include a link to your project on CodePen and click the "I've completed this challenge" button.
|
||||
Quando hai finito, includi un link al tuo progetto su CodePen e clicca sul pulsante "Ho completato questa sfida".
|
||||
|
||||
You can get feedback on your project by sharing it on the [freeCodeCamp forum](https://forum.freecodecamp.org/c/project-feedback/409).
|
||||
Puoi ottenere un feedback sul tuo progetto condividendolo sul forum [freeCodeCamp](https://forum.freecodecamp.org/c/project-feedback/409).
|
||||
|
||||
# --solutions--
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: bd7158d8c443edefaeb5bdee
|
||||
title: Build an Image Search Abstraction Layer
|
||||
title: Crea un Livello di astrazione Ricerca Immagine
|
||||
challengeType: 4
|
||||
forumTopicId: 302361
|
||||
dashedName: build-an-image-search-abstraction-layer
|
||||
@ -8,17 +8,17 @@ dashedName: build-an-image-search-abstraction-layer
|
||||
|
||||
# --description--
|
||||
|
||||
Build a full stack JavaScript app that allows you to search for images like this: <https://image-search-abstraction-layer.freecodecamp.rocks/query/lolcats%20funny?page=10> and browse recent search queries like this: <https://image-search-abstraction-layer.freecodecamp.rocks/recent/>. Use a site builder of your choice to complete the project.
|
||||
Costruisci una app JavaScript full stack che ti permette di cercare immagini come questa: <https://image-search-abstraction-layer.freecodecamp.rocks/query/lolcats%20funny?page=10> e navigare tra ricerce recenti come questa: <https://image-search-abstraction-layer.freecodecamp.rocks/recent/>. Usa un costruttore di siti di tua scelta per completare il progetto.
|
||||
|
||||
Here are the specific user stories you should implement for this project:
|
||||
Ecco le specifiche user story da implementare per questo progetto:
|
||||
|
||||
**User Story:** You can get the image URLs, description and page URLs for a set of images relating to a given search string.
|
||||
**User Story:** Puoi ottenere le URL delle immagini, una descrizione e le URL delle pagine per un set di immagini relative ad una data stringa di ricerca.
|
||||
|
||||
**User Story:** You can paginate through the responses by adding a `?page=2` parameter to the URL.
|
||||
**User Story:** Puoi navigare tra le pagine dei risultati aggiungendo un parametro `?page=2` all'URL.
|
||||
|
||||
**User Story:** You can get a list of the most recently submitted search strings.
|
||||
**User Story:** Puoi ottenere una lista delle stringhe usate più di recente per la ricerca.
|
||||
|
||||
When you are done, make sure a working demo of your project is hosted somewhere public. Then submit the URL to it in the `Solution Link` field. Optionally, also submit a link to your project's source code in the `GitHub Link` field.
|
||||
Quando hai finito, assicurati che una demo funzionante del tuo progetto sia ospitata in qualche percorso pubblico. Quindi invia l'URL nel campo `Solution Link`. Facoltativamente, invia anche un link al codice sorgente del tuo progetto nel campo `GitHub Link`.
|
||||
|
||||
# --solutions--
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: bd7154d8c242eddfaeb5bd13
|
||||
title: Build the Game of Life
|
||||
title: Costruisci il Gioco della Vita
|
||||
challengeType: 3
|
||||
forumTopicId: 302362
|
||||
dashedName: build-the-game-of-life
|
||||
@ -8,29 +8,29 @@ dashedName: build-the-game-of-life
|
||||
|
||||
# --description--
|
||||
|
||||
**Objective:** Build a [CodePen.io](https://codepen.io) app that is functionally similar to this: <https://codepen.io/freeCodeCamp/full/BpwMZv/>.
|
||||
**Obiettivo:** Costruisci un'app [CodePen.io](https://codepen.io) funzionalmente simile a questa: [https://codepen.io/freeCodeCamp/full/BpwMZv](https://codepen.io/freeCodeCamp/full/BpwMZv/).
|
||||
|
||||
Fulfill the below [user stories](https://en.wikipedia.org/wiki/User_story). Use whichever libraries or APIs you need. Give it your own personal style.
|
||||
Soddisfa le seguenti [user story](https://en.wikipedia.org/wiki/User_story). Utilizza le librerie o le API di cui hai bisogno. Usa il tuo stile personale.
|
||||
|
||||
**User Story:** When I first arrive at the game, it will randomly generate a board and start playing.
|
||||
**User Story:** Quando apro il gioco, genererà casualmente un tabellone e inizierà a giocare.
|
||||
|
||||
**User Story:** I can start and stop the board.
|
||||
**User Story:** Posso iniziare e fermare il tabellore.
|
||||
|
||||
**User Story:** I can set up the board.
|
||||
**User Story:** Posso configurare il tabellone.
|
||||
|
||||
**User Story:** I can clear the board.
|
||||
**User Story:** Posso pulire il tabellone.
|
||||
|
||||
**User Story:** When I press start, the game will play out.
|
||||
**User Story:** Quando premo start, il gioco inizierà.
|
||||
|
||||
**User Story:** Each time the board changes, I can see how many generations have gone by.
|
||||
**User Story:** Ogni volta che il tabellone cambia, posso vedere quante generazioni sono passate.
|
||||
|
||||
**Hint:** Here's an explanation of Conway's Game of Life from John Conway himself: <https://www.youtube.com/watch?v=E8kUJL04ELA>
|
||||
**Suggerimento:**Ecco una spiegazione del Gioco della Vita di Conway da John Conway stesso: <https://www.youtube.com/watch?v=E8kUJL04ELA>
|
||||
|
||||
**Hint:** Here's an overview of Conway's Game of Life with rules for your reference: [https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life](https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life)
|
||||
**Suggerimento:** Ecco una descrizione del Gioco della Vita di Conway con le regole per tuo riferimento: [https://it.wikipedia.org/wiki/Gioco_della_vita](https://it.wikipedia.org/wiki/Gioco_della_vita)
|
||||
|
||||
When you are finished, include a link to your project on CodePen and click the "I've completed this challenge" button.
|
||||
Quando hai finito, includi un link al tuo progetto su CodePen e clicca sul pulsante "Ho completato questa sfida".
|
||||
|
||||
You can get feedback on your project by sharing it on the [freeCodeCamp forum](https://forum.freecodecamp.org/c/project-feedback/409).
|
||||
Puoi ottenere un feedback sul tuo progetto condividendolo sul forum [freeCodeCamp](https://forum.freecodecamp.org/c/project-feedback/409).
|
||||
|
||||
# --solutions--
|
||||
|
||||
|
@ -33,11 +33,15 @@ io.use(
|
||||
);
|
||||
```
|
||||
|
||||
Certifique-se de adicionar a `key` e a `store` no middleware `session` montado na aplicação. Isto é necessário para informar ao *SocketIO* a qual sessão ele deve se relacionar.
|
||||
Observe que configurar a autenticação do Passport para o Socket.IO é muito parecido com a maneira como configuramos o middleware `session` para a API. Isso ocorre porque eles devem usar o mesmo método de autenticação — obter o id da sessão de um cookie e validá-lo.
|
||||
|
||||
Anteriormente, quando configuramos o middleware `session`, não definimos explicitamente o nome do cookie para a sessão (`key`). Isso ocorre porque o pacote de `session` estava usando o valor padrão. Agora que adicionamos outro pacote que precisa acessar o mesmo valor a partir dos cookies, precisamos definir explicitamente o valor de `key` em ambos os objetos de configuração.
|
||||
|
||||
Certifique-se de adicionar `key` com o nome do cookie para o middleware `session` que corresponde à chave do Socket.IO. Além disso, adicione a referência de `store` às opções, perto de onde configuramos `saveUninitialized: true`. Isto é necessário para informar ao SocketIO a qual sessão ele deve se relacionar.
|
||||
|
||||
<hr />
|
||||
|
||||
Agora, defina as funções de `success` e `fail` na função de callback:
|
||||
Agora, defina as funções de `success` e `fail` nas funções de callback:
|
||||
|
||||
```js
|
||||
function onAuthorizeSuccess(data, accept) {
|
||||
@ -53,7 +57,7 @@ function onAuthorizeFail(data, message, error, accept) {
|
||||
}
|
||||
```
|
||||
|
||||
Agora, o objeto de usuário está acessível no seu objeto de socket como `socket.request.user`. Por exemplo, agora, você pode adicionar o seguinte:
|
||||
Agora, o objeto de usuário está acessível no objeto de socket como `socket.request.user`. Por exemplo, agora, você pode adicionar o seguinte:
|
||||
|
||||
```js
|
||||
console.log('user ' + socket.request.user.name + ' connected');
|
||||
|
Reference in New Issue
Block a user