chore(i18n,learn): processed translations (#45001)
This commit is contained in:
@ -11,7 +11,7 @@ dashedName: use-tabindex-to-add-keyboard-focus-to-an-element
|
||||
|
||||
El atributo HTML `tabindex` tiene tres funciones distintas relacionadas con el foco del teclado de un elemento. Cuando está en una etiqueta, indica que se puede hacer foco en el elemento. El valor (un número entero que es positivo, negativo o cero) determina el comportamiento.
|
||||
|
||||
Ciertos elementos, como los vínculos y los controles de formulario, reciben automáticamente el foco del teclado cuando un usuario pestañas a través de una página. Está en el mismo orden en que los elementos vienen en la fuente del lenguaje de marcado de HTML. Esta misma funcionalidad se puede dar a otros elementos, como `div`, `span` y `p`, colocando un atributo `tabindex="0"`. Aquí hay un ejemplo:
|
||||
Algunos elementos, como los enlaces y los controles de los formularios, reciben automáticamente el foco del teclado cuando un usuario tabula por una página. Está en el mismo orden en que los elementos vienen en la fuente del lenguaje de marcado de HTML. Esta misma funcionalidad se puede dar a otros elementos, como `div`, `span` y `p`, colocando un atributo `tabindex="0"`. Aquí hay un ejemplo:
|
||||
|
||||
```html
|
||||
<div tabindex="0">I need keyboard focus!</div>
|
||||
|
@ -8,7 +8,7 @@ dashedName: render-conditionally-from-props
|
||||
|
||||
# --description--
|
||||
|
||||
Hasta ahora, has visto cómo usar `if/else`, `&&`y el operador ternario (`condition ? expressionIfTrue : expressionIfFalse`) para tomar decisiones condicionales sobre qué renderizar y cuándo. Sin embargo, queda un tema importante por discutir que te permite combinar cualquier o todos estos conceptos con otra poderosa característica de React: los props. El uso de props para renderizar condicionalmente el código es muy común entre los desarrolladores de React, es decir, utilizan el valor de una prop dada para automáticamente tomar decisiones sobre qué renderizar.
|
||||
Hasta ahora, has visto cómo utilizar `if/else`, `&&`, y el operador ternario (`condition ? expressionIfTrue : expressionIfFalse`) para tomar decisiones condicionales sobre qué renderizar y cuándo. Sin embargo, queda un tema importante por discutir que te permite combinar cualquiera o todos estos conceptos con otra poderosa característica de React: las props. El uso de props para renderizar condicionalmente el código es muy común entre los desarrolladores de React, es decir, utilizan el valor de una prop dada para automáticamente tomar decisiones sobre qué renderizar.
|
||||
|
||||
En este desafío, configurarás un componente hijo para tomar decisiones de renderizado basadas en props. También usarás el operador ternario, pero puedes ver cómo varios de los otros conceptos que se cubrieron en los últimos desafíos podrían ser igual de útiles en este contexto.
|
||||
|
||||
|
@ -128,14 +128,15 @@ assert(
|
||||
if (typeof test.remove !== 'function') {
|
||||
return false;
|
||||
}
|
||||
test.add(-1);
|
||||
test.add(1);
|
||||
test.add(4);
|
||||
test.add(3);
|
||||
test.add(7);
|
||||
test.add(16);
|
||||
test.remove(16);
|
||||
test.remove(7);
|
||||
test.add(2);
|
||||
test.add(6);
|
||||
test.add(8);
|
||||
test.remove(6);
|
||||
test.remove(3);
|
||||
return test.inorder().join('') == '-1';
|
||||
return test.inorder().join('') == '1248';
|
||||
})()
|
||||
);
|
||||
```
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 594810f028c0303b75339ace
|
||||
title: Accumulator factory
|
||||
title: Fabbrica di accumulatori
|
||||
challengeType: 5
|
||||
forumTopicId: 302222
|
||||
dashedName: accumulator-factory
|
||||
@ -8,41 +8,41 @@ dashedName: accumulator-factory
|
||||
|
||||
# --description--
|
||||
|
||||
A problem posed by [Paul Graham](https://en.wikipedia.org/wiki/Paul_Graham_(programmer)) is that of creating a function that takes a single (numeric) argument and which returns another function that is an accumulator. The returned accumulator function in turn also takes a single numeric argument, and returns the sum of all the numeric values passed in so far to that accumulator (including the initial value passed when the accumulator was created).
|
||||
Un problema posto da [Paul Graham](https://it.wikipedia.org/wiki/Paul_Graham_(informatico)) è quello di creare una funzione che accetta un singolo argomento (numerico) e che restituisce un'altra funzione che è un accumulatore. A sua volta anche la funzione accumulatrice restituita accetta un singolo argomento numerico, e restituisce la somma di tutti i valori numerici passati finora a quell'accumulatore (incluso il valore iniziale passato quando l'accumulatore è stato creato).
|
||||
|
||||
# --instructions--
|
||||
|
||||
Create a function that takes a number $n$ and generates accumulator functions that return the sum of every number ever passed to them.
|
||||
Crea una funzione che prende un numero $n$ e genera funzioni accumulatrici che restituiscono la somma di ogni numero passato a loro.
|
||||
|
||||
**Rules:**
|
||||
**Regole:**
|
||||
|
||||
Do not use global variables.
|
||||
Non usare variabili globali.
|
||||
|
||||
**Hint:**
|
||||
**Suggerimento:**
|
||||
|
||||
Closures save outer state.
|
||||
La chiusura salva lo stato esterno.
|
||||
|
||||
# --hints--
|
||||
|
||||
`accumulator` should be a function.
|
||||
`accumulator` dovrebbe essere una funzione.
|
||||
|
||||
```js
|
||||
assert(typeof accumulator === 'function');
|
||||
```
|
||||
|
||||
`accumulator(0)` should return a function.
|
||||
`accumulator(0)` dovrebbe restituire una funzione.
|
||||
|
||||
```js
|
||||
assert(typeof accumulator(0) === 'function');
|
||||
```
|
||||
|
||||
`accumulator(0)(2)` should return a number.
|
||||
`accumulator(0)(2)` dovrebbe restituire un numero.
|
||||
|
||||
```js
|
||||
assert(typeof accumulator(0)(2) === 'number');
|
||||
```
|
||||
|
||||
Passing in the values 3, -4, 1.5, and 5 should return 5.5.
|
||||
Passare i valori 3, -4, 1.5, e 5 dovrebbe restituire 5.5.
|
||||
|
||||
```js
|
||||
assert(testFn(5) === 5.5);
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 594810f028c0303b75339acf
|
||||
title: Ackermann function
|
||||
title: La funzione di Ackermann
|
||||
challengeType: 5
|
||||
forumTopicId: 302223
|
||||
dashedName: ackermann-function
|
||||
@ -8,45 +8,45 @@ dashedName: ackermann-function
|
||||
|
||||
# --description--
|
||||
|
||||
The Ackermann function is a classic example of a recursive function, notable especially because it is not a primitive recursive function. It grows very quickly in value, as does the size of its call tree.
|
||||
La funzione di Ackermann è un esempio classico di una funzione ricorsiva, degna di nota soprattutto perché non è una funzione ricorsiva primitiva. Cresce molto in fretta in valore, come fa anche la dimensione del suo albero di invocazioni.
|
||||
|
||||
The Ackermann function is usually defined as follows:
|
||||
La funzione di Ackermann è usualmente definita come segue:
|
||||
|
||||
$A(m, n) = \\begin{cases} n+1 & \\mbox{if } m = 0 \\\\ A(m-1, 1) & \\mbox{if } m > 0 \\mbox{ and } n = 0 \\\\ A(m-1, A(m, n-1)) & \\mbox{if } m > 0 \\mbox{ and } n > 0. \\end{cases}$
|
||||
|
||||
Its arguments are never negative and it always terminates.
|
||||
I suoi argomenti non sono mai negativi e termina sempre.
|
||||
|
||||
# --instructions--
|
||||
|
||||
Write a function which returns the value of $A(m, n)$. Arbitrary precision is preferred (since the function grows so quickly), but not required.
|
||||
Scrivi una funzione che restituisce il valore di $A(m, n)$. Precisione arbitraria è preferita (poiché la funzione cresce così rapidamente), ma non è necessaria.
|
||||
|
||||
# --hints--
|
||||
|
||||
`ack` should be a function.
|
||||
`ack` dovrebbe essere una funzione.
|
||||
|
||||
```js
|
||||
assert(typeof ack === 'function');
|
||||
```
|
||||
|
||||
`ack(0, 0)` should return 1.
|
||||
`ack(0, 0)` dovrebbe restituire 1.
|
||||
|
||||
```js
|
||||
assert(ack(0, 0) === 1);
|
||||
```
|
||||
|
||||
`ack(1, 1)` should return 3.
|
||||
`ack(1, 1)` dovrebbe restituire 3.
|
||||
|
||||
```js
|
||||
assert(ack(1, 1) === 3);
|
||||
```
|
||||
|
||||
`ack(2, 5)` should return 13.
|
||||
`ack(2, 5)` dovrebbe restituire 13.
|
||||
|
||||
```js
|
||||
assert(ack(2, 5) === 13);
|
||||
```
|
||||
|
||||
`ack(3, 3)` should return 61.
|
||||
`ack(3, 3)` dovrebbe restituire 61.
|
||||
|
||||
```js
|
||||
assert(ack(3, 3) === 61);
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 594810f028c0303b75339ad0
|
||||
title: Align columns
|
||||
title: Allineare colonne
|
||||
challengeType: 5
|
||||
forumTopicId: 302224
|
||||
dashedName: align-columns
|
||||
@ -8,11 +8,11 @@ dashedName: align-columns
|
||||
|
||||
# --description--
|
||||
|
||||
Given an array of many lines, where fields within a line are delineated by a single `$` character, write a program that aligns each column of fields by ensuring that words in each column are separated by at least one space. Further, allow for each word in a column to be either left justified, right justified, or center justified within its column.
|
||||
Dato un array di molte righe, dove campi in una singola linea sono delimitati da un singolo carattere `$`, scrivi un programma che allinea ogni colonna di campi assicurandoti che le parole in ogni colonna sono separate da almeno uno spazio. In più, permetti ad ogni parola in una colonna di essere o allineata a destra, o allineata a sinistra, o allineata al centro nella sua colonna.
|
||||
|
||||
# --instructions--
|
||||
|
||||
Use the following text to test your programs:
|
||||
Usa il seguente testo per testare i tuoi programmi:
|
||||
|
||||
```js
|
||||
const testText = [
|
||||
@ -29,16 +29,16 @@ const testText = [
|
||||
];
|
||||
```
|
||||
|
||||
**Note that:**
|
||||
**Nota che:**
|
||||
|
||||
- The example input texts lines may, or may not, have trailing dollar characters.
|
||||
- All columns should share the same alignment.
|
||||
- Consecutive space characters produced adjacent to the end of lines are insignificant for the purposes of the task.
|
||||
- Output text will be viewed in a mono-spaced font on a plain text editor or basic terminal. Lines in it should be joined using new line character (`\n`).
|
||||
- The minimum space between columns should be computed from the text and not hard-coded.
|
||||
- It is not a requirement to add separating characters between or around columns.
|
||||
- Le righe di testo di esempio possono avere o no caratteri di dollaro finali.
|
||||
- Tutte le colonne dovrebbero condividere lo stesso allineamento.
|
||||
- I caratteri spazio consecutivi prodotti adiacenti alla fine delle linee sono insignificanti ai fini del compito.
|
||||
- Il testo di output sarà visualizzato in un carattere mono-spaziato su un editor di testo semplice o un terminale base. Le righe in esso dovrebbero essere unite utilizzando un carattere nuova riga (`\n`).
|
||||
- Lo spazio minimo tra le colonne dovrebbe essere calcolato dal testo e non codificato.
|
||||
- Non è un requisito aggiungere caratteri di separazione tra colonne o intorno a colonne.
|
||||
|
||||
For example, one of the lines from the `testText`, after jusitifing to the right, left and center respectivelly:
|
||||
Ad esempio, una delle righe del `testText`, dopo aver giustificato rispettivamente a destra, sinistra, e centro:
|
||||
|
||||
```js
|
||||
' column are separated by at least one space.\n'
|
||||
@ -48,25 +48,25 @@ For example, one of the lines from the `testText`, after jusitifing to the right
|
||||
|
||||
# --hints--
|
||||
|
||||
`formatText` should be a function.
|
||||
`formatText` dovrebbe essere una funzione.
|
||||
|
||||
```js
|
||||
assert(typeof formatText === 'function');
|
||||
```
|
||||
|
||||
`formatText(testText, 'right')` should produce text with columns justified to the right.
|
||||
`formatText(testText, 'right')` dovrebbe produrre testo con le colonne allineate a destra.
|
||||
|
||||
```js
|
||||
assert.strictEqual(formatText(_testText, 'right'), rightAligned);
|
||||
```
|
||||
|
||||
`formatText(testText, 'left')` should produce text with columns justified to the left.
|
||||
`formatText(testText, 'left')` dovrebbe produrre testo con le colonne allineate a sinistra.
|
||||
|
||||
```js
|
||||
assert.strictEqual(formatText(_testText, 'left'), leftAligned);
|
||||
```
|
||||
|
||||
`formatText(testText, 'center')` should produce text with columns justified to the center.
|
||||
`formatText(testText, 'center')` dovrebbe produrre testo con le colonne allineate al centro.
|
||||
|
||||
```js
|
||||
assert.strictEqual(formatText(_testText, 'center'), centerAligned);
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 5949b579404977fbaefcd737
|
||||
title: Amicable pairs
|
||||
title: Coppie amicabili
|
||||
challengeType: 5
|
||||
forumTopicId: 302225
|
||||
dashedName: amicable-pairs
|
||||
@ -8,42 +8,42 @@ dashedName: amicable-pairs
|
||||
|
||||
# --description--
|
||||
|
||||
Two integers $N$ and $M$ are said to be [amicable pairs](https://en.wikipedia.org/wiki/Amicable numbers "wp: Amicable numbers") if $N \\neq M$ and the sum of the [proper divisors](https://rosettacode.org/wiki/Proper divisors "Proper divisors") of $N$ ($\\mathrm{sum}(\\mathrm{propDivs}(N))$) $= M$ as well as $\\mathrm{sum}(\\mathrm{propDivs}(M)) = N$.
|
||||
Due numeri interi $N$ e $M$ sono detti [Numeri amicabili](https://it.wikipedia.org/wiki/Numeri_amicabili) se $N \\neq M$ e la somma dei [divisori propri](https://rosettacode.org/wiki/Proper divisors "Proper divisors") di $N$ ($\\mathrm{sum}(\\mathrm{propDivs}(N))$) $= M$ e $\\mathrm{sum}(\\mathrm{propDivs}(M)) = N$.
|
||||
|
||||
**Example:**
|
||||
**Esempio:**
|
||||
|
||||
**1184** and **1210** are an amicable pair, with proper divisors:
|
||||
**1184** e **1210** sono una coppia amicabile, con i seguenti divisori propri:
|
||||
|
||||
<ul>
|
||||
<li>1, 2, 4, 8, 16, 32, 37, 74, 148, 296, 592 and</li>
|
||||
<li>1, 2, 5, 10, 11, 22, 55, 110, 121, 242, 605 respectively.</li>
|
||||
<li>1, 2, 4, 8, 16, 32, 37, 74, 148, 296, 592 e</li>
|
||||
<li>1, 2, 5, 10, 11, 22, 55, 110, 121, 242, 605 rispettivamente.</li>
|
||||
</ul>
|
||||
|
||||
# --instructions--
|
||||
|
||||
Calculate and show here the Amicable pairs below 20,000 (there are eight).
|
||||
Calcola e mostra qui le coppie amicabili sotto 20 000 (ce ne sono otto).
|
||||
|
||||
# --hints--
|
||||
|
||||
`amicablePairsUpTo` should be a function.
|
||||
`amicablePairsUpTo` dovrebbe essere una funzione.
|
||||
|
||||
```js
|
||||
assert(typeof amicablePairsUpTo === 'function');
|
||||
```
|
||||
|
||||
`amicablePairsUpTo(300)` should return `[[220,284]]`.
|
||||
`amicablePairsUpTo(300)` dovrebbe restituire `[[220,284]]`.
|
||||
|
||||
```js
|
||||
assert.deepEqual(amicablePairsUpTo(300), answer300);
|
||||
```
|
||||
|
||||
`amicablePairsUpTo(3000)` should return `[[220,284],[1184,1210],[2620,2924]]`.
|
||||
`amicablePairsUpTo(3000)` dovrebbe restituire `[[220,284],[1184,1210],[2620,2924]]`.
|
||||
|
||||
```js
|
||||
assert.deepEqual(amicablePairsUpTo(3000), answer3000);
|
||||
```
|
||||
|
||||
`amicablePairsUpTo(20000)` should return `[[220,284],[1184,1210],[2620,2924],[5020,5564],[6232,6368],[10744,10856],[12285,14595],[17296,18416]]`.
|
||||
`amicablePairsUpTo(20000)` dovrebbe restituire `[[220,284],[1184,1210],[2620,2924],[5020,5564],[6232,6368],[10744,10856],[12285,14595],[17296,18416]]`.
|
||||
|
||||
```js
|
||||
assert.deepEqual(amicablePairsUpTo(20000), answer20000);
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 594d8d0ab97724821379b1e6
|
||||
title: Averages/Mode
|
||||
title: Medie/Moda
|
||||
challengeType: 5
|
||||
forumTopicId: 302226
|
||||
dashedName: averagesmode
|
||||
@ -8,27 +8,27 @@ dashedName: averagesmode
|
||||
|
||||
# --description--
|
||||
|
||||
Write a program to find the [mode](https://en.wikipedia.org/wiki/Mode (statistics) "wp: Mode (statistics)") value of a collection.
|
||||
Scrivi un programma per trovare il valore [moda](https://it.wikipedia.org/wiki/Moda_(statistica) "Moda (statistica)") di una collezione.
|
||||
|
||||
The case where the collection is empty may be ignored. Care must be taken to handle the case where the mode is non-unique.
|
||||
Il caso in cui una collezione è vuota può essere ignorato. Devi fare attenzione per gestire il caso dove la moda non è unica.
|
||||
|
||||
If it is not appropriate or possible to support a general collection, use a vector (array), if possible. If it is not appropriate or possible to support an unspecified value type, use integers.
|
||||
Se non è appropriato o possibile supportare una collezione generale, usa un vettore (array), se possibile. Se non è appropriato o possibile supportare un tipo di valore non specificato, usa numeri interi.
|
||||
|
||||
# --hints--
|
||||
|
||||
`mode` should be a function.
|
||||
`mode` dovrebbe essere una funzione.
|
||||
|
||||
```js
|
||||
assert(typeof mode === 'function');
|
||||
```
|
||||
|
||||
`mode([1, 3, 6, 6, 6, 6, 7, 7, 12, 12, 17])` should equal `[6]`
|
||||
`mode([1, 3, 6, 6, 6, 6, 7, 7, 12, 12, 17])` dovrebbe essere uguale a `[6]`
|
||||
|
||||
```js
|
||||
assert.deepEqual(mode(arr1), [6]);
|
||||
```
|
||||
|
||||
`mode([1, 2, 4, 4, 1])` should equal `[1, 4]`.
|
||||
`mode([1, 2, 4, 4, 1])` dovrebbe essere uguale a `[1, 4]`.
|
||||
|
||||
```js
|
||||
assert.deepEqual(mode(arr2).sort(), [1, 4]);
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 594d966a1467eb84194f0086
|
||||
title: Averages/Pythagorean means
|
||||
title: Medie/medie pitagoriche
|
||||
challengeType: 5
|
||||
forumTopicId: 302227
|
||||
dashedName: averagespythagorean-means
|
||||
@ -8,24 +8,24 @@ dashedName: averagespythagorean-means
|
||||
|
||||
# --description--
|
||||
|
||||
Compute all three of the [Pythagorean means](https://en.wikipedia.org/wiki/Pythagorean means "wp: Pythagorean means") of the set of integers $1$ through $10$ (inclusive).
|
||||
Calcola le tre [medie pitagoriche](https://en.wikipedia.org/wiki/Pythagorean means "wp: Pythagorean means") dei numeri interi tra $1$ e $10$ (inclusivo).
|
||||
|
||||
Show that $A(x_1,\\ldots,x_n) \\geq G(x_1,\\ldots,x_n) \\geq H(x_1,\\ldots,x_n)$ for this set of positive integers.
|
||||
Mostra che $A(x_1,\\ldots,x_n) \\geq G(x_1,\\ldots,x_n) \\geq H(x_1,\\ldots,x_n)$ per questo set di numeri positivi interi.
|
||||
|
||||
<ul>
|
||||
<li>The most common of the three means, the <a class='rosetta__link--rosetta' href='https://rosettacode.org/wiki/Averages/Arithmetic mean' title='Averages/Arithmetic mean' target='_blank'>arithmetic mean</a>, is the sum of the list divided by its length:<br>
|
||||
<li>La più comune delle tre medie, la <a class='rosetta__link--rosetta' href='https://rosettacode.org/wiki/Averages/Arithmetic mean' title='Averages/Arithmetic mean' target='_blank'>media aritmetica</a>, è la somma della lista divisa dalla sua lunghezza:<br>
|
||||
<big>$ A(x_1, \ldots, x_n) = \frac{x_1 + \cdots + x_n}{n}$</big></li>
|
||||
<li>The <a class='rosetta__link--wiki' href='https://en.wikipedia.org/wiki/Geometric mean' title='wp: Geometric mean' target='_blank'>geometric mean</a> is the $n$th root of the product of the list:<br>
|
||||
<li>La <a class='rosetta__link--wiki' href='https://en.wikipedia.org/wiki/Geometric mean' title='wp: Geometric mean' target='_blank'>media geometrica</a> è l'$n$-sima radice del prodotto della lista:<br>
|
||||
<big>$ G(x_1, \ldots, x_n) = \sqrt[n]{x_1 \cdots x_n} $</big></li>
|
||||
<li>The <a class='rosetta__link--wiki' href='https://en.wikipedia.org/wiki/Harmonic mean' title='wp: Harmonic mean' target='_blank'>harmonic mean</a> is $n$ divided by the sum of the reciprocal of each item in the list:<br>
|
||||
<li>La <a class='rosetta__link--wiki' href='https://en.wikipedia.org/wiki/Harmonic mean' title='wp: Harmonic mean' target='_blank'>media armonica</a> è $n$ diviso la somma dei reciproci di ogni elemento della lista:<br>
|
||||
<big>$ H(x_1, \ldots, x_n) = \frac{n}{\frac{1}{x_1} + \cdots + \frac{1}{x_n}} $</big></li>
|
||||
</ul>
|
||||
|
||||
# --instructions--
|
||||
|
||||
When writing your function, assume the input is an ordered array of all inclusive numbers.
|
||||
Quando scrivi la funzione, assumi che l'input sia un array ordinato inclusivo di tutti i numeri.
|
||||
|
||||
For the answer, please output an object in the following format:
|
||||
Per l'output per favore usa un oggetto del seguente formato:
|
||||
|
||||
```js
|
||||
{
|
||||
@ -40,13 +40,13 @@ For the answer, please output an object in the following format:
|
||||
|
||||
# --hints--
|
||||
|
||||
`pythagoreanMeans` should be a function.
|
||||
`pythagoreanMeans` dovrebbe essere una funzione.
|
||||
|
||||
```js
|
||||
assert(typeof pythagoreanMeans === 'function');
|
||||
```
|
||||
|
||||
`pythagoreanMeans([1, 2, ..., 10])` should equal the same output above.
|
||||
`pythagoreanMeans([1, 2, ..., 10])` dovrebbe avere lo stesso output di sopra.
|
||||
|
||||
```js
|
||||
assert.deepEqual(pythagoreanMeans(range1), answer1);
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 594da033de4190850b893874
|
||||
title: Averages/Root mean square
|
||||
title: Medie/Valore efficace
|
||||
challengeType: 5
|
||||
forumTopicId: 302228
|
||||
dashedName: averagesroot-mean-square
|
||||
@ -8,23 +8,23 @@ dashedName: averagesroot-mean-square
|
||||
|
||||
# --description--
|
||||
|
||||
Compute the [Root mean square](https://en.wikipedia.org/wiki/Root mean square "wp: Root mean square") of the numbers 1 through 10 inclusive.
|
||||
Calcola il [Valore efficace](https://it.wikipedia.org/wiki/Valore_efficace "wp: Valore efficace") dei numeri da 1 a 10 inclusivo.
|
||||
|
||||
The *root mean square* is also known by its initials RMS (or rms), and as the **quadratic mean**.
|
||||
Il *valore efficace* è anche noto con le iniziali RMS (o rms dall'inglese root mean square), e come **media quadratica**.
|
||||
|
||||
The RMS is calculated as the mean of the squares of the numbers, square-rooted:
|
||||
Il RMS è calcolato come la radice quadrata della media dei quadrati dei numeri:
|
||||
|
||||
$$x\_{\\mathrm{rms}} = \\sqrt {{{x_1}^2 + {x_2}^2 + \\cdots + {x_n}^2} \\over n}. $$
|
||||
|
||||
# --hints--
|
||||
|
||||
`rms` should be a function.
|
||||
`rms` dovrebbe essere una funzione.
|
||||
|
||||
```js
|
||||
assert(typeof rms === 'function');
|
||||
```
|
||||
|
||||
`rms([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])` should equal `6.2048368229954285`.
|
||||
`rms([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])` dovrebbe essere uguale a `6.2048368229954285`.
|
||||
|
||||
```js
|
||||
assert.equal(rms(arr1), answer1);
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 594db4d0dedb4c06a2a4cefd
|
||||
title: Babbage problem
|
||||
title: Il problema di Babbage
|
||||
challengeType: 5
|
||||
forumTopicId: 302229
|
||||
dashedName: babbage-problem
|
||||
@ -8,30 +8,30 @@ dashedName: babbage-problem
|
||||
|
||||
# --description--
|
||||
|
||||
[Charles Babbage](https://en.wikipedia.org/wiki/Charles_Babbage "wp: Charles_Babbage"), looking ahead to the sorts of problems his Analytical Engine would be able to solve, gave this example:
|
||||
[Charles Babbage](https://it.wikipedia.org/wiki/Charles_Babbage "wp: Charles_Babbage"), guardando al futuro di quello che la sua Macchina Analitica avrebbe potuto risolvere, diede questo esempio:
|
||||
|
||||
<blockquote>
|
||||
What is the smallest positive integer whose square ends in the digits 269,696?
|
||||
<footer style='margin-left: 2em;'>Babbage, letter to Lord Bowden, 1837; see Hollingdale and Tootill, <i>Electronic Computers</i>, second edition, 1970, p. 125.</footer>
|
||||
Quale è il più piccolo numero positivo intero il quale quadrato finisce con le cifre 269696?
|
||||
<footer style='margin-left: 2em;'>Traduzione da Babbage, letter to Lord Bowden, 1837; see Hollingdale and Tootill, <i>Electronic Computers</i>, second edition, 1970, p. 125.</footer>
|
||||
</blockquote>
|
||||
|
||||
He thought the answer might be 99,736, whose square is 9,947,269,696; but he couldn't be certain.
|
||||
Pensava che la risposta potesse essere 99.736, il cui quadrato è 9.947.269.696; ma non poteva esserne certo.
|
||||
|
||||
The task is to find out if Babbage had the right answer.
|
||||
Questa sfida riguarda trovare se Babbage avesse la risposta giusta.
|
||||
|
||||
# --instructions--
|
||||
|
||||
Implement a function to return the lowest integer that satisfies the Babbage problem. If Babbage was right, return Babbage's number.
|
||||
Implementa una funzione che restituisce il più piccolo numero intero che soddisfa il problema di Babbage. Se Babbage aveva ragione, restituisci il numero di Babbage.
|
||||
|
||||
# --hints--
|
||||
|
||||
`babbage` should be a function.
|
||||
`babbage` dovrebbe essere una funzione.
|
||||
|
||||
```js
|
||||
assert(typeof babbage === 'function');
|
||||
```
|
||||
|
||||
`babbage(99736, 269696)` should not return 99736 (there is a smaller answer).
|
||||
`babbage(99736, 269696)` non dovrebbe restituire 99736 (c'è una risposta più piccola).
|
||||
|
||||
```js
|
||||
assert.equal(babbage(babbageAns, endDigits), answer);
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 594dc6c729e5700999302b45
|
||||
title: Balanced brackets
|
||||
title: Parentesi bilanciate
|
||||
challengeType: 5
|
||||
forumTopicId: 302230
|
||||
dashedName: balanced-brackets
|
||||
@ -8,9 +8,9 @@ dashedName: balanced-brackets
|
||||
|
||||
# --description--
|
||||
|
||||
Determine whether a generated string of brackets is balanced; that is, whether it consists entirely of pairs of opening/closing brackets (in that order), none of which mis-nest.
|
||||
Determina se la stringa generata di parentesi è bilanciata; cioè, se consiste di coppie di parentesi aperte/chiuse (in quell'ordine), nessuno dei quali è annidata nel modo sbagliato.
|
||||
|
||||
**Examples:**
|
||||
**Esempi:**
|
||||
| Input | Output |
|
||||
| ------------------------- | ------ |
|
||||
| <code>\[]</code> | true |
|
||||
@ -22,115 +22,115 @@ Determine whether a generated string of brackets is balanced; that is, whether i
|
||||
|
||||
# --hints--
|
||||
|
||||
`isBalanced` should be a function.
|
||||
`isBalanced` dovrebbe essere una funzione.
|
||||
|
||||
```js
|
||||
assert(typeof isBalanced === 'function');
|
||||
```
|
||||
|
||||
`isBalanced("[]")` should return true.
|
||||
`isBalanced("[]")` dovrebbe restituire true.
|
||||
|
||||
```js
|
||||
assert(isBalanced(testCases[0]));
|
||||
```
|
||||
|
||||
`isBalanced("]][[[][][][]][")` should return false.
|
||||
`isBalanced("]][[[][][][]][")` dovrebbe restituire false.
|
||||
|
||||
```js
|
||||
assert(!isBalanced(testCases[1]));
|
||||
```
|
||||
|
||||
`isBalanced("[][[[[][][[[]]]]]]")` should return true.
|
||||
`isBalanced("[][[[[][][[[]]]]]]")` dovrebbe restituire true.
|
||||
|
||||
```js
|
||||
assert(isBalanced(testCases[2]));
|
||||
```
|
||||
|
||||
`isBalanced("][")` should return false.
|
||||
`isBalanced("][")` dovrebbe restituire false.
|
||||
|
||||
```js
|
||||
assert(!isBalanced(testCases[3]));
|
||||
```
|
||||
|
||||
`isBalanced("[[[]]]][[]")` should return false.
|
||||
`isBalanced("[[[]]]][[]")` dovrebbe restituire false.
|
||||
|
||||
```js
|
||||
assert(!isBalanced(testCases[4]));
|
||||
```
|
||||
|
||||
`isBalanced("][[]")` should return false.
|
||||
`isBalanced("][[]")` dovrebbe restituire false.
|
||||
|
||||
```js
|
||||
assert(!isBalanced(testCases[5]));
|
||||
```
|
||||
|
||||
`isBalanced("][[][]][[[]]")` should return false.
|
||||
`isBalanced("][[][]][[[]]")` dovrebbe restituire false.
|
||||
|
||||
```js
|
||||
assert(!isBalanced(testCases[6]));
|
||||
```
|
||||
|
||||
`isBalanced("[[][]]][")` should return false.
|
||||
`isBalanced("[[][]]][")` dovrebbe restituire false.
|
||||
|
||||
```js
|
||||
assert(!isBalanced(testCases[7]));
|
||||
```
|
||||
|
||||
`isBalanced("[[[]]][[]]]][][[")` should return false.
|
||||
`isBalanced("[[[]]][[]]]][][[")` dovrebbe restituire false.
|
||||
|
||||
```js
|
||||
assert(!isBalanced(testCases[8]));
|
||||
```
|
||||
|
||||
`isBalanced("[]][[]]][[[[][]]")` should return false.
|
||||
`isBalanced("[]][[]]][[[[][]]")` dovrebbe restituire false.
|
||||
|
||||
```js
|
||||
assert(!isBalanced(testCases[9]));
|
||||
```
|
||||
|
||||
`isBalanced("][]][[][")` should return false.
|
||||
`isBalanced("][]][[][")` dovrebbe restituire false.
|
||||
|
||||
```js
|
||||
assert(!isBalanced(testCases[10]));
|
||||
```
|
||||
|
||||
`isBalanced("[[]][[][]]")` should return true.
|
||||
`isBalanced("[[]][[][]]")` dovrebbe restituire true.
|
||||
|
||||
```js
|
||||
assert(isBalanced(testCases[11]));
|
||||
```
|
||||
|
||||
`isBalanced("[[]]")` should return true.
|
||||
`isBalanced("[[]]")` dovrebbe restituire true.
|
||||
|
||||
```js
|
||||
assert(isBalanced(testCases[12]));
|
||||
```
|
||||
|
||||
`isBalanced("]][]][[]][[[")` should return false.
|
||||
`isBalanced("]][]][[]][[[")` dovrebbe restituire false.
|
||||
|
||||
```js
|
||||
assert(!isBalanced(testCases[13]));
|
||||
```
|
||||
|
||||
`isBalanced("][]][][[")` should return false.
|
||||
`isBalanced("][]][][[")` dovrebbe restituire false.
|
||||
|
||||
```js
|
||||
assert(!isBalanced(testCases[14]));
|
||||
```
|
||||
|
||||
`isBalanced("][][")` should return false.
|
||||
`isBalanced("][][")` dovrebbe restituire false.
|
||||
|
||||
```js
|
||||
assert(!isBalanced(testCases[15]));
|
||||
```
|
||||
|
||||
`isBalanced("[]]]")` should return false.
|
||||
`isBalanced("[]]]")` dovrebbe restituire false.
|
||||
|
||||
```js
|
||||
assert(!isBalanced(testCases[16]));
|
||||
```
|
||||
|
||||
`isBalanced("")` should return true.
|
||||
`isBalanced("")` dovrebbe restituire true.
|
||||
|
||||
```js
|
||||
assert(isBalanced(testCases[17]));
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 5951815dd895584b06884620
|
||||
title: Circles of given radius through two points
|
||||
title: Cerchi di raggio dato attraverso due punti
|
||||
challengeType: 5
|
||||
forumTopicId: 302231
|
||||
dashedName: circles-of-given-radius-through-two-points
|
||||
@ -8,30 +8,30 @@ dashedName: circles-of-given-radius-through-two-points
|
||||
|
||||
# --description--
|
||||
|
||||
Given two points on a plane and a radius, usually two circles of given radius can be drawn through the points.
|
||||
Dati due punti su un piano, e un raggio, in genere due cerchi di raggio dato possono essere disegnati attraverso i punti.
|
||||
|
||||
**Exceptions:**
|
||||
**Eccezioni:**
|
||||
|
||||
<ul>
|
||||
<li>A radius of zero should be treated as never describing circles (except in the case where the points are coincident).</li>
|
||||
<li>If the points are coincident then an infinite number of circles with the point on their circumference can be drawn, unless the radius is equal to zero as well which then collapses the circles to a point.</li>
|
||||
<li>If the points form a diameter then return a single circle.</li>
|
||||
<li>If the points are too far apart then no circles can be drawn.</li>
|
||||
<li>Un raggio di zero deve essere trattato come non descrivente mai cerchi (eccetto nel caso in cui i punti sono coincidenti).</li>
|
||||
<li>Se i punti sono coincidenti allora si può disegnare un numero infinito di cerchi con i punti sulla loro circonferenza; a meno che il raggio non sia pure uguale a zero, il che collassa i cerchi a un punto.</li>
|
||||
<li>Se i punti formano un diametro allora restituisci un singolo cerchio.</li>
|
||||
<li>Se i punti sono troppo distanti allora nessun cerchio può essere disegnato.</li>
|
||||
</ul>
|
||||
|
||||
# --instructions--
|
||||
|
||||
Implement a function that takes two points and a radius and returns the two circles through those points. For each resulting circle, provide the coordinates for the center of each circle rounded to four decimal digits. Return each coordinate as an array, and coordinates as an array of arrays.
|
||||
Implementa una funzione che accetta due punti e un raggio e restituisce i due cerchi attraverso quei punti. Per ogni cerchio risultante, provvedi le coordinate del centro di ogni cerchio arrotondate a quattro cifre decimali. Restituisci ogni coordinata come un array, e le coordinate come un array di array.
|
||||
|
||||
**For edge cases, return the following:**
|
||||
**Per casi limite, restituisci le cose seguenti:**
|
||||
|
||||
<ul>
|
||||
<li>If points are on the diameter, return one point. If the radius is also zero however, return <code>"Radius Zero"</code>.</li>
|
||||
<li>If points are coincident, return <code>"Coincident point. Infinite solutions"</code>.</li>
|
||||
<li>If points are farther apart than the diameter, return <code>"No intersection. Points further apart than circle diameter"</code>.</li>
|
||||
<li>Se i punti sono sul diametro, restituisci un punto. Se il raggio è pure zero allora restituisci <code>"Radius Zero"</code>.</li>
|
||||
<li>Se i punti sono coincidenti, restituisci <code>"Coincident point. Infinite solutions"</code>.</li>
|
||||
<li>Se i punti sono più distanti tra loro del diametro, restituisci <code>"No intersection. Points further apart than circle diameter"</code>.</li>
|
||||
</ul>
|
||||
|
||||
**Sample inputs:**
|
||||
**Esempio di input:**
|
||||
|
||||
<pre> p1 p2 r
|
||||
0.1234, 0.9876 0.8765, 0.2345 2.0
|
||||
@ -43,37 +43,37 @@ Implement a function that takes two points and a radius and returns the two circ
|
||||
|
||||
# --hints--
|
||||
|
||||
`getCircles` should be a function.
|
||||
`getCircles` dovrebbe essere una funzione.
|
||||
|
||||
```js
|
||||
assert(typeof getCircles === 'function');
|
||||
```
|
||||
|
||||
`getCircles([0.1234, 0.9876], [0.8765, 0.2345], 2.0)` should return `[[1.8631, 1.9742], [-0.8632, -0.7521]]`.
|
||||
`getCircles([0.1234, 0.9876], [0.8765, 0.2345], 2.0)` dovrebbe restituire `[[1.8631, 1.9742], [-0.8632, -0.7521]]`.
|
||||
|
||||
```js
|
||||
assert.deepEqual(getCircles(...testCases[0]), answers[0]);
|
||||
```
|
||||
|
||||
`getCircles([0.0000, 2.0000], [0.0000, 0.0000], 1.0)` should return `[0, 1]`
|
||||
`getCircles([0.0000, 2.0000], [0.0000, 0.0000], 1.0)` dovrebbe restituire `[0, 1]`
|
||||
|
||||
```js
|
||||
assert.deepEqual(getCircles(...testCases[1]), answers[1]);
|
||||
```
|
||||
|
||||
`getCircles([0.1234, 0.9876], [0.1234, 0.9876], 2.0)` should return `Coincident point. Infinite solutions`
|
||||
`getCircles([0.1234, 0.9876], [0.1234, 0.9876], 2.0)` dovrebbe restituire `Coincident point. Infinite solutions`
|
||||
|
||||
```js
|
||||
assert.deepEqual(getCircles(...testCases[2]), answers[2]);
|
||||
```
|
||||
|
||||
`getCircles([0.1234, 0.9876], [0.8765, 0.2345], 0.5)` should return `No intersection. Points further apart than circle diameter`
|
||||
`getCircles([0.1234, 0.9876], [0.8765, 0.2345], 0.5)` dovrebbe restituire `No intersection. Points further apart than circle diameter`
|
||||
|
||||
```js
|
||||
assert.deepEqual(getCircles(...testCases[3]), answers[3]);
|
||||
```
|
||||
|
||||
`getCircles([0.1234, 0.9876], [0.1234, 0.9876], 0.0)` should return `Radius Zero`
|
||||
`getCircles([0.1234, 0.9876], [0.1234, 0.9876], 0.0)` dovrebbe restituire `Radius Zero`
|
||||
|
||||
```js
|
||||
assert.deepEqual(getCircles(...testCases[4]), answers[4]);
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 5951a53863c8a34f02bf1bdc
|
||||
title: Closest-pair problem
|
||||
title: Problema della coppia più vicina
|
||||
challengeType: 5
|
||||
forumTopicId: 302232
|
||||
dashedName: closest-pair-problem
|
||||
@ -8,11 +8,11 @@ dashedName: closest-pair-problem
|
||||
|
||||
# --description--
|
||||
|
||||
Provide a function to find the closest two points among a set of given points in two dimensions.
|
||||
Crea una funzione che trova i due punti più vicini tra quelli in un set di punti in due dimensioni.
|
||||
|
||||
The straightforward solution is a $O(n^2)$ algorithm (which we can call *brute-force algorithm*); the pseudo-code (using indexes) could be simply:
|
||||
La soluzione diretta è un algoritmo $O(n^2)$ (che possiamo chiamare *algoritmo a forza bruta* (brute-force)); lo pseudo-codice (usando indici) potrebbe essere semplicemente:
|
||||
|
||||
<pre><strong>bruteForceClosestPair</strong> of P(1), P(2), ... P(N)
|
||||
<pre><strong>bruteForceClosestPair</strong> di P(1), P(2), ... P(N)
|
||||
<strong>if</strong> N < 2 <strong>then</strong>
|
||||
<strong>return</strong> ∞
|
||||
<strong>else</strong>
|
||||
@ -30,7 +30,7 @@ The straightforward solution is a $O(n^2)$ algorithm (which we can call *brute-f
|
||||
<strong>endif</strong>
|
||||
</pre>
|
||||
|
||||
A better algorithm is based on the recursive divide and conquer approach, which is $O(n\log n)$ a pseudo-code could be:
|
||||
Un algoritmo migliore è basato sull'approccio ricorsivo dividi e conquista, che è $O(n\log n)$, uno pseudocodice potrebbe essere:
|
||||
|
||||
<pre><strong>closestPair</strong> of (xP, yP)
|
||||
where xP is P(1) .. P(N) sorted by x coordinate, and
|
||||
@ -65,9 +65,9 @@ A better algorithm is based on the recursive divide and conquer approach, which
|
||||
<strong>endif</strong>
|
||||
</pre>
|
||||
|
||||
For the input, expect the argument to be an array of `Point` objects with `x` and `y` members set to numbers. Return an object containing the key:value pairs for `distance` and `pair` (the pair of two closest points).
|
||||
Per l'input, aspettati che l'argomento sia un array di oggetti `Point` con i membri `x` e `y` impostati come numeri. Restituisci un oggetto contenete le coppie chiave-valore per `distance` e `pair` (la coppia dei due punti più vicini).
|
||||
|
||||
For example `getClosestPair` with input array `points`:
|
||||
Per esempio `getClosestPair` con input array `points`:
|
||||
|
||||
```js
|
||||
const points = [
|
||||
@ -77,7 +77,7 @@ const points = [
|
||||
];
|
||||
```
|
||||
|
||||
Would return:
|
||||
Restituirebbe:
|
||||
|
||||
```js
|
||||
{
|
||||
@ -95,24 +95,24 @@ Would return:
|
||||
}
|
||||
```
|
||||
|
||||
**Note:** Sort the `pair` array by their `x` values in incrementing order.
|
||||
**Nota:** Ordina l'array `pair` secondo i valori `x` in ordine crescente.
|
||||
|
||||
|
||||
# --hints--
|
||||
|
||||
`getClosestPair` should be a function.
|
||||
`getClosestPair` dovrebbe essere una funzione.
|
||||
|
||||
```js
|
||||
assert(typeof getClosestPair === 'function');
|
||||
```
|
||||
|
||||
`getClosestPair(points1).distance` should be `0.0894096443343775`.
|
||||
`getClosestPair(points1).distance` dovrebbe essere `0.0894096443343775`.
|
||||
|
||||
```js
|
||||
assert.equal(getClosestPair(points1).distance, answer1.distance);
|
||||
```
|
||||
|
||||
`getClosestPair(points1).pair` should be `[ { x: 7.46489, y: 4.6268 }, { x: 7.46911, y: 4.71611 } ]`.
|
||||
`getClosestPair(points1).pair` dovrebbe essere `[ { x: 7.46489, y: 4.6268 }, { x: 7.46911, y: 4.71611 } ]`.
|
||||
|
||||
```js
|
||||
assert.deepEqual(
|
||||
@ -121,13 +121,13 @@ assert.deepEqual(
|
||||
);
|
||||
```
|
||||
|
||||
`getClosestPair(points2).distance` should be `65.06919393998976`.
|
||||
`getClosestPair(points2).distance` dovrebbe essere `65.06919393998976`.
|
||||
|
||||
```js
|
||||
assert.equal(getClosestPair(points2).distance, answer2.distance);
|
||||
```
|
||||
|
||||
`getClosestPair(points2).pair` should be `[ { x: 37134, y: 1963 }, { x: 37181, y: 2008 } ]`.
|
||||
`getClosestPair(points2).pair` dovrebbe essere `[ { x: 37134, y: 1963 }, { x: 37181, y: 2008 } ]`.
|
||||
|
||||
```js
|
||||
assert.deepEqual(
|
||||
@ -136,13 +136,13 @@ assert.deepEqual(
|
||||
);
|
||||
```
|
||||
|
||||
`getClosestPair(points3).distance` should be `6754.625082119658`.
|
||||
`getClosestPair(points3).distance` dovrebbe essere `6754.625082119658`.
|
||||
|
||||
```js
|
||||
assert.equal(getClosestPair(points3).distance, answer3.distance);
|
||||
```
|
||||
|
||||
`getClosestPair(points3).pair` should be `[ { x: 46817, y: 64975 }, { x: 48953, y: 58567 } ]`.
|
||||
`getClosestPair(points3).pair` dovrebbe essere `[ { x: 46817, y: 64975 }, { x: 48953, y: 58567 } ]`.
|
||||
|
||||
```js
|
||||
assert.deepEqual(
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 5958469238c0d8d2632f46db
|
||||
title: Combinations
|
||||
title: Combinazioni
|
||||
challengeType: 5
|
||||
forumTopicId: 302233
|
||||
dashedName: combinations
|
||||
@ -8,11 +8,11 @@ dashedName: combinations
|
||||
|
||||
# --description--
|
||||
|
||||
Given non-negative integers `m` and `n`, generate all size `m` combinations of the integers from `0` (zero) to `n-1` in sorted order (each combination is sorted and the entire table is sorted).
|
||||
Dati i due numeri interi non negativi `m` e `n`, genera tutte le combinazioni di dimensione `m` dei numeri interi da `0` (zero) a `n-1` ordinati (ogni combinazione è ordinata e la tabella intera è ordinata).
|
||||
|
||||
**Example:**
|
||||
**Per esempio:**
|
||||
|
||||
`3` comb `5` is:
|
||||
`3` comb `5` è:
|
||||
|
||||
<pre>0 1 2
|
||||
0 1 3
|
||||
@ -28,19 +28,19 @@ Given non-negative integers `m` and `n`, generate all size `m` combinations of t
|
||||
|
||||
# --hints--
|
||||
|
||||
`combinations` should be a function.
|
||||
`combinations` dovrebbe essere una funzione.
|
||||
|
||||
```js
|
||||
assert(typeof combinations === 'function');
|
||||
```
|
||||
|
||||
`combinations(3, 5)` should return `[[0, 1, 2], [0, 1, 3], [0, 1, 4], [0, 2, 3], [0, 2, 4], [0, 3, 4], [1, 2, 3], [1, 2, 4], [1, 3, 4], [2, 3, 4]]`.
|
||||
`combinations(3, 5)` dovrebbe restituire `[[0, 1, 2], [0, 1, 3], [0, 1, 4], [0, 2, 3], [0, 2, 4], [0, 3, 4], [1, 2, 3], [1, 2, 4], [1, 3, 4], [2, 3, 4]]`.
|
||||
|
||||
```js
|
||||
assert.deepEqual(combinations(testInput1[0], testInput1[1]), testOutput1);
|
||||
```
|
||||
|
||||
`combinations(4, 6)` should return `[[0,1,2,3], [0,1,2,4], [0,1,2,5], [0,1,3,4], [0,1,3,5], [0,1,4,5], [0,2,3,4], [0,2,3,5], [0,2,4,5], [0,3,4,5], [1,2,3,4], [1,2,3,5], [1,2,4,5], [1,3,4,5], [2,3,4,5]]`
|
||||
`combinations(4, 6)` dovrebbe restituire `[[0,1,2,3], [0,1,2,4], [0,1,2,5], [0,1,3,4], [0,1,3,5], [0,1,4,5], [0,2,3,4], [0,2,3,5], [0,2,4,5], [0,3,4,5], [1,2,3,4], [1,2,3,5], [1,2,4,5], [1,3,4,5], [2,3,4,5]]`
|
||||
|
||||
```js
|
||||
assert.deepEqual(combinations(testInput2[0], testInput2[1]), testOutput2);
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 596e414344c3b2872167f0fe
|
||||
title: Comma quibbling
|
||||
title: Cavillare
|
||||
challengeType: 5
|
||||
forumTopicId: 302234
|
||||
dashedName: comma-quibbling
|
||||
@ -8,63 +8,63 @@ dashedName: comma-quibbling
|
||||
|
||||
# --description--
|
||||
|
||||
Comma quibbling is a task originally set by Eric Lippert in his [blog](https://blogs.msdn.com/b/ericlippert/archive/2009/04/15/comma-quibbling.aspx).
|
||||
Cavillare è un compito originariamente creato da Eric Lipper sul suo [blog](https://blogs.msdn.com/b/ericlippert/archive/2009/04/15/comma-quibbling.aspx).
|
||||
|
||||
# --instructions--
|
||||
|
||||
Write a function to generate a string output which is the concatenation of input words from a list/sequence where:
|
||||
Scrivi una funzione per generare una stringa output che è la concatenazione di parole di input da una lista/sequenza dove:
|
||||
|
||||
<ol>
|
||||
<li>An input of no words produces the output string of just the two brace characters (<code>"{}"</code>)</li>
|
||||
<li>An input of just one word, e.g. <code>["ABC"]</code>, produces the output string of the word inside the two braces, e.g. <code>"{ABC}"</code></li>
|
||||
<li>An input of two words, e.g. <code>["ABC", "DEF"]</code>, produces the output string of the two words inside the two braces with the words separated by the string <code>" and "</code>, e.g. <code>"{ABC and DEF}"</code></li>
|
||||
<li>An input of three or more words, e.g. <code>["ABC", "DEF", "G", "H"]</code>, produces the output string of all but the last word separated by <code>", "</code> with the last word separated by <code>" and "</code> and all within braces; e.g. <code>"{ABC, DEF, G and H}"</code></li>
|
||||
<li>Un input senza parole produce una stringa output con solo due parentesi graffe (<code>"{}"</code>)</li>
|
||||
<li>Un input di una sola parola, per esempio <code>["ABC"]</code> produce una stringa output con la parola dentro due parentesi graffe (<code>"{ABC}"</code>)</li>
|
||||
<li>Un input di due parole, per esempio <code>["ABC", "DEF"]</code> produce una stringa output con due parole dentro le due parentesi graffe con le parole separate dalla stringa <code>" and "</code>, per esempio (<code>"{ABC and DEF}"</code>)</li>
|
||||
<li>Un input di tre o più parole, per esempio <code>["ABC", "DEF", "G", "H"]</code> produce una stringa output con tutte le parole, tranne le ultime due, separate da <code>", "</code>, e con l'ultima parola separata da <code>" and "</code>; per esempio (<code>"{ABC, DEF, G and H}"</code>)</li>
|
||||
</ol>
|
||||
|
||||
Test your function with the following series of inputs showing your output here on this page:
|
||||
Testa la tua funzione con la seguente serie di input mostrando il tuo output qui sulla pagina:
|
||||
|
||||
<ul>
|
||||
<li>[] # (No input words).</li>
|
||||
<li>[] # (Nessuna parola di input).</li>
|
||||
<li>["ABC"]</li>
|
||||
<li>["ABC", "DEF"]</li>
|
||||
<li>["ABC", "DEF", "G", "H"]</li>
|
||||
</ul>
|
||||
|
||||
**Note:** Assume words are non-empty strings of uppercase characters for this task.
|
||||
**Nota:** Assumi che le parole siano stringhe non vuote di caratteri maiuscoli per questa sfida.
|
||||
|
||||
# --hints--
|
||||
|
||||
`quibble` should be a function.
|
||||
`quibble` dovrebbe essere una funzione.
|
||||
|
||||
```js
|
||||
assert(typeof quibble === 'function');
|
||||
```
|
||||
|
||||
`quibble(["ABC"])` should return a string.
|
||||
`quibble(["ABC"])` dovrebbe restituire una stringa.
|
||||
|
||||
```js
|
||||
assert(typeof quibble(['ABC']) === 'string');
|
||||
```
|
||||
|
||||
`quibble([])` should return "{}".
|
||||
`quibble([])` dovrebbe restituire "{}".
|
||||
|
||||
```js
|
||||
assert.equal(quibble(testCases[0]), results[0]);
|
||||
```
|
||||
|
||||
`quibble(["ABC"])` should return "{ABC}".
|
||||
`quibble(["ABC"])` dovrebbe restituire "{ABC}".
|
||||
|
||||
```js
|
||||
assert.equal(quibble(testCases[1]), results[1]);
|
||||
```
|
||||
|
||||
`quibble(["ABC", "DEF"])` should return "{ABC and DEF}".
|
||||
`quibble(["ABC", "DEF"])` dovrebbe restituire "{ABC and DEF}".
|
||||
|
||||
```js
|
||||
assert.equal(quibble(testCases[2]), results[2]);
|
||||
```
|
||||
|
||||
`quibble(["ABC", "DEF", "G", "H"])` should return "{ABC,DEF,G and H}".
|
||||
`quibble(["ABC", "DEF", "G", "H"])` dovrebbe restituire "{ABC,DEF,G and H}".
|
||||
|
||||
```js
|
||||
assert.equal(quibble(testCases[3]), results[3]);
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 596e457071c35c882915b3e4
|
||||
title: Compare a list of strings
|
||||
title: Confronta un elenco di stringhe
|
||||
challengeType: 5
|
||||
forumTopicId: 302235
|
||||
dashedName: compare-a-list-of-strings
|
||||
@ -8,82 +8,82 @@ dashedName: compare-a-list-of-strings
|
||||
|
||||
# --description--
|
||||
|
||||
Given a [list](https://en.wikipedia.org/wiki/List_(abstract_data_type) "wp: List\_(abstract_data_type)") of arbitrarily many strings, implement a function for each of the following conditions:
|
||||
Data una [lista](https://it.wikipedia.org/wiki/Lista_(informatica)) di un numero arbitrario di stringhe, implementa una funzione per ognuna delle seguenti condizioni:
|
||||
|
||||
<ul>
|
||||
<li>test if they are all lexically equal</li>
|
||||
<li>test if every string is lexically less than the one after it (i.e. whether the list is in strict ascending order)</li>
|
||||
<li>testa se sono tutte lessicamente uguali</li>
|
||||
<li>testa se ogni stringa è lessicamente inferiore di quella successiva (cioè se la lista è in ordine ascendente)</li>
|
||||
</ul>
|
||||
|
||||
# --hints--
|
||||
|
||||
`allEqual` should be a function.
|
||||
`allEqual` dovrebbe essere una funzione.
|
||||
|
||||
```js
|
||||
assert(typeof allEqual === 'function');
|
||||
```
|
||||
|
||||
`azSorted` should be a function.
|
||||
`azSorted` dovrebbe essere una funzione.
|
||||
|
||||
```js
|
||||
assert(typeof azSorted === 'function');
|
||||
```
|
||||
|
||||
`allEqual(["AA", "AA", "AA", "AA"])` should return true.
|
||||
`allEqual(["AA", "AA", "AA", "AA"])` dovrebbe restituire true.
|
||||
|
||||
```js
|
||||
assert(allEqual(testCases[0]));
|
||||
```
|
||||
|
||||
`azSorted(["AA", "AA", "AA", "AA"])` should return false.
|
||||
`azSorted(["AA", "AA", "AA", "AA"])` dovrebbe restituire false.
|
||||
|
||||
```js
|
||||
assert(!azSorted(testCases[0]));
|
||||
```
|
||||
|
||||
`allEqual(["AA", "ACB", "BB", "CC"])` should return false.
|
||||
`allEqual(["AA", "ACB", "BB", "CC"])` dovrebbe restituire false.
|
||||
|
||||
```js
|
||||
assert(!allEqual(testCases[1]));
|
||||
```
|
||||
|
||||
`azSorted(["AA", "ACB", "BB", "CC"])` should return true.
|
||||
`azSorted(["AA", "ACB", "BB", "CC"])` dovrebbe restituire true.
|
||||
|
||||
```js
|
||||
assert(azSorted(testCases[1]));
|
||||
```
|
||||
|
||||
`allEqual([])` should return true.
|
||||
`allEqual([])` dovrebbe restituire true.
|
||||
|
||||
```js
|
||||
assert(allEqual(testCases[2]));
|
||||
```
|
||||
|
||||
`azSorted([])` should return true.
|
||||
`azSorted([])` dovrebbe restituire true.
|
||||
|
||||
```js
|
||||
assert(azSorted(testCases[2]));
|
||||
```
|
||||
|
||||
`allEqual(["AA"])` should return true.
|
||||
`allEqual(["AA"])` dovrebbe restituire true.
|
||||
|
||||
```js
|
||||
assert(allEqual(testCases[3]));
|
||||
```
|
||||
|
||||
`azSorted(["AA"])` should return true.
|
||||
`azSorted(["AA"])` dovrebbe restituire true.
|
||||
|
||||
```js
|
||||
assert(azSorted(testCases[3]));
|
||||
```
|
||||
|
||||
`allEqual(["BB", "AA"])` should return false.
|
||||
`allEqual(["BB", "AA"])` dovrebbe restituire false.
|
||||
|
||||
```js
|
||||
assert(!allEqual(testCases[4]));
|
||||
```
|
||||
|
||||
`azSorted(["BB", "AA"])` should return false.
|
||||
`azSorted(["BB", "AA"])` dovrebbe restituire false.
|
||||
|
||||
```js
|
||||
assert(!azSorted(testCases[4]));
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 596fd036dc1ab896c5db98b1
|
||||
title: Convert seconds to compound duration
|
||||
title: Convertire secondi in durata composta
|
||||
challengeType: 5
|
||||
forumTopicId: 302236
|
||||
dashedName: convert-seconds-to-compound-duration
|
||||
@ -8,69 +8,69 @@ dashedName: convert-seconds-to-compound-duration
|
||||
|
||||
# --description--
|
||||
|
||||
Implement a function which:
|
||||
Implementa una funzione che:
|
||||
|
||||
<ul>
|
||||
<li>takes a positive integer representing a duration in seconds as input (e.g., <code>100</code>), and</li>
|
||||
<li>returns a string which shows the same duration decomposed into weeks, days, hours, minutes, and seconds as detailed below (e.g., <code>1 min, 40 sec</code>).</li>
|
||||
<li>accetta un numero intero positivo che rappresenta una durata in secondi come input (ad esempio, <code>100</code>), e</li>
|
||||
<li>restituisce una stringa che mostra la stessa durata decomposta in settimane, giorni, ore, minuti e secondi come dettagliato sotto (per esempio, <code>1 min, 40 sec</code>).</li>
|
||||
</ul>
|
||||
|
||||
Demonstrate that it passes the following three test-cases:
|
||||
Dimostra che passi i seguenti tre casi:
|
||||
|
||||
<div style='font-size:115%; font-weight: bold;'>Test Cases</div>
|
||||
<div style='font-size:115%; font-weight: bold;'>Test</div>
|
||||
|
||||
| Input number | Output number |
|
||||
| ------------ | ------------------------- |
|
||||
| 7259 | <code>2 hr, 59 sec</code> |
|
||||
| 86400 | <code>1 d</code> |
|
||||
| 6000000 | <code>9 wk, 6 d, 10 hr, 40 min</code> |
|
||||
| Numero di input | Numero di output |
|
||||
| --------------- | ------------------------- |
|
||||
| 7259 | <code>2 hr, 59 sec</code> |
|
||||
| 86400 | <code>1 d</code> |
|
||||
| 6000000 | <code>9 wk, 6 d, 10 hr, 40 min</code> |
|
||||
|
||||
<div style="font-size:115%; font-weight: bold;">Details</div>
|
||||
<div style="font-size:115%; font-weight: bold;">Dettagli</div>
|
||||
<ul>
|
||||
<li>
|
||||
The following five units should be used:
|
||||
Le seguenti cinque unita dovrebbero essere usate:
|
||||
|
||||
| Unit | Suffix used in Output | Conversion |
|
||||
| Unità | Suffisso usato in output | Conversione |
|
||||
| ------ | --------------------- | --------------------- |
|
||||
| week |!!crwdBlockTags_18_sgaTkcolBdwrc!! | 1 week = 7 days |
|
||||
| day |!!crwdBlockTags_19_sgaTkcolBdwrc!! | 1 day = 24 hours |
|
||||
| hour |!!crwdBlockTags_20_sgaTkcolBdwrc!! | 1 hour = 60 minutes |
|
||||
| minute |!!crwdBlockTags_21_sgaTkcolBdwrc!! | 1 minute = 60 seconds |
|
||||
| settimana |!!crwdBlockTags_18_sgaTkcolBdwrc!! | 1 settimana = 7 giorni |
|
||||
| giorno |!!crwdBlockTags_19_sgaTkcolBdwrc!! | 1 giorno = 24 ore |
|
||||
| ora |!!crwdBlockTags_20_sgaTkcolBdwrc!! | 1 ora = 60 minuti |
|
||||
| minuti |!!crwdBlockTags_21_sgaTkcolBdwrc!! | 1 minuto = 60 secondi |
|
||||
| second |!!crwdBlockTags_22_sgaTkcolBdwrc!! | --- |
|
||||
|
||||
</li>
|
||||
<li>
|
||||
However, <strong>only</strong> include quantities with non-zero values in the output (e.g., return <code>1 d</code> and not <code>0 wk, 1 d, 0 hr, 0 min, 0 sec</code>).
|
||||
Però, includi <strong>solo</strong> quantità con valori non-zero nell'output (per esempio restituisce<code>1 d</code> e non <code>0 wk, 1 d, 0 hr, 0 min, 0 sec</code>).
|
||||
</li>
|
||||
<li>
|
||||
Give larger units precedence over smaller ones as much as possible (e.g., return <code>2 min, 10 sec</code> and not <code>1 min, 70 sec</code> or <code>130 sec</code>).
|
||||
Dai la precedenza alle unità più grandi il più possibile (per esempio, restituisci <code>2 min, 10 sec</code> e non <code>1 min, 70 sec</code> o <code>130 sec</code>).
|
||||
</li>
|
||||
<li>
|
||||
Mimic the formatting shown in the test-cases (quantities sorted from largest unit to smallest and separated by comma+space; value and unit of each quantity separated by space).
|
||||
Mimica il formato mostrato nell'esempio (quantità in ordine dalla più grande alla più piccola e separate da virgola e spazio, valore e unità di ogni quantità separate da uno spazio).
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
# --hints--
|
||||
|
||||
`convertSeconds` should be a function.
|
||||
`convertSeconds` dovrebbe essere una funzione.
|
||||
|
||||
```js
|
||||
assert(typeof convertSeconds === 'function');
|
||||
```
|
||||
|
||||
`convertSeconds(7259)` should return `2 hr, 59 sec`.
|
||||
`convertSeconds(7259)` dovrebbe restituire `2 hr, 59 sec`.
|
||||
|
||||
```js
|
||||
assert.equal(convertSeconds(testCases[0]), results[0]);
|
||||
```
|
||||
|
||||
`convertSeconds(86400)` should return `1 d`.
|
||||
`convertSeconds(86400)` dovrebbe restituire `1 d`.
|
||||
|
||||
```js
|
||||
assert.equal(convertSeconds(testCases[1]), results[1]);
|
||||
```
|
||||
|
||||
`convertSeconds(6000000)` should return `9 wk, 6 d, 10 hr, 40 min`.
|
||||
`convertSeconds(6000000)` dovrebbe restituire `9 wk, 6 d, 10 hr, 40 min`.
|
||||
|
||||
```js
|
||||
assert.equal(convertSeconds(testCases[2]), results[2]);
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 596fda99c69f779975a1b67d
|
||||
title: Count occurrences of a substring
|
||||
title: Contare le occorrenze di una sottostringa
|
||||
challengeType: 5
|
||||
forumTopicId: 302237
|
||||
dashedName: count-occurrences-of-a-substring
|
||||
@ -8,42 +8,42 @@ dashedName: count-occurrences-of-a-substring
|
||||
|
||||
# --description--
|
||||
|
||||
Create a function, or show a built-in function, to count the number of non-overlapping occurrences of a substring inside a string.
|
||||
Crea una funzione, o mostra una funzione integrata, per contare il numero di occorrenze non sovrapposte di una sottostringa all'interno di una stringa.
|
||||
|
||||
The function should take two arguments:
|
||||
La funzione dovrebbe prendere due argomenti:
|
||||
|
||||
<ul>
|
||||
<li>the first argument being the string to search, and</li>
|
||||
<li>the second a substring to be searched for.</li>
|
||||
<li>il primo argomento è la stringa da esaminare, e</li>
|
||||
<li>il secondo la sotto-stringa da trovare.</li>
|
||||
</ul>
|
||||
|
||||
It should return an integer count.
|
||||
Dovrebbe restituire un numero intero.
|
||||
|
||||
The matching should yield the highest number of non-overlapping matches.
|
||||
La ricerca dovrebbe produrre il maggior numero di sottostringhe non sovrapposte.
|
||||
|
||||
In general, this essentially means matching from left-to-right or right-to-left.
|
||||
In generale, questo significa essenzialmente cercare da sinistra a destra o da destra a sinistra.
|
||||
|
||||
# --hints--
|
||||
|
||||
`countSubstring` should be a function.
|
||||
`countSubstring` dovrebbe essere una funzione.
|
||||
|
||||
```js
|
||||
assert(typeof countSubstring === 'function');
|
||||
```
|
||||
|
||||
`countSubstring("the three truths", "th")` should return `3`.
|
||||
`countSubstring("the three truths", "th")` dovrebbe restituire `3`.
|
||||
|
||||
```js
|
||||
assert.equal(countSubstring(testCases[0], searchString[0]), results[0]);
|
||||
```
|
||||
|
||||
`countSubstring("ababababab", "abab")` should return `2`.
|
||||
`countSubstring("ababababab", "abab")` dovrebbe restituire `2`.
|
||||
|
||||
```js
|
||||
assert.equal(countSubstring(testCases[1], searchString[1]), results[1]);
|
||||
```
|
||||
|
||||
`countSubstring("abaabba*bbaba*bbab", "a*b")` should return `2`.
|
||||
`countSubstring("abaabba*bbaba*bbab", "a*b")` dovrebbe restituire `2`.
|
||||
|
||||
```js
|
||||
assert.equal(countSubstring(testCases[2], searchString[2]), results[2]);
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 59713bd26bdeb8a594fb9413
|
||||
title: Count the coins
|
||||
title: Contare le monete
|
||||
challengeType: 5
|
||||
forumTopicId: 302238
|
||||
dashedName: count-the-coins
|
||||
@ -8,51 +8,51 @@ dashedName: count-the-coins
|
||||
|
||||
# --description--
|
||||
|
||||
There are four types of common coins in [US](https://en.wikipedia.org/wiki/United_States) currency:
|
||||
Ci sono quattro tipi di monete comuni nella valuta degli [Stati Uniti d'America](https://it.wikipedia.org/wiki/Stati_Uniti_d%27America):
|
||||
|
||||
<ul>
|
||||
<li>quarters (25 cents)</li>
|
||||
<li>dimes (10 cents)</li>
|
||||
<li>nickels (5 cents), and</li>
|
||||
<li>pennies (1 cent)</li>
|
||||
<li>quarter (25 centesimi)</li>
|
||||
<li>dime (10 centesimi)</li>
|
||||
<li>nickel (5 centesimi), e</li>
|
||||
<li>penny (1 centesimo)</li>
|
||||
</ul>
|
||||
|
||||
<p>There are six ways to make change for 15 cents:</p>
|
||||
<p>Ci sono sei modi per ottenere 15 centesimi:</p>
|
||||
|
||||
<ul>
|
||||
<li>A dime and a nickel</li>
|
||||
<li>A dime and 5 pennies</li>
|
||||
<li>3 nickels</li>
|
||||
<li>2 nickels and 5 pennies</li>
|
||||
<li>A nickel and 10 pennies</li>
|
||||
<li>15 pennies</li>
|
||||
<li>Un dime e un nickel</li>
|
||||
<li>Un dime e 5 penny</li>
|
||||
<li>3 nickel</li>
|
||||
<li>2 nickel e 5 penny</li>
|
||||
<li>Un nickel e 10 penny</li>
|
||||
<li>15 penny</li>
|
||||
</ul>
|
||||
|
||||
# --instructions--
|
||||
|
||||
Implement a function to determine how many ways there are to make change for a given input, `cents`, that represents an amount of US pennies using these common coins.
|
||||
Implementa una funzione che determina quanti modi diversi ci sono per ottenere un certo input, `cents`, che rappresenta il numero di centesimi, usando queste monete comuni.
|
||||
|
||||
# --hints--
|
||||
|
||||
`countCoins` should be a function.
|
||||
`countCoins` dovrebbe essere una funzione.
|
||||
|
||||
```js
|
||||
assert(typeof countCoins === 'function');
|
||||
```
|
||||
|
||||
`countCoins(15)` should return `6`.
|
||||
`countCoins(15)` dovrebbe restituire `6`.
|
||||
|
||||
```js
|
||||
assert.equal(countCoins(15), 6);
|
||||
```
|
||||
|
||||
`countCoins(85)` shouls return `163`.
|
||||
`countCoins(85)` dovrebbe restituire `163`.
|
||||
|
||||
```js
|
||||
assert.equal(countCoins(85), 163);
|
||||
```
|
||||
|
||||
`countCoins(100)` should return `242`.
|
||||
`countCoins(100)` dovrebbe restituire `242`.
|
||||
|
||||
```js
|
||||
assert.equal(countCoins(100), 242);
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 59713da0a428c1a62d7db430
|
||||
title: Cramer's rule
|
||||
title: Regola di Cramer
|
||||
challengeType: 5
|
||||
forumTopicId: 302239
|
||||
dashedName: cramers-rule
|
||||
@ -8,43 +8,43 @@ dashedName: cramers-rule
|
||||
|
||||
# --description--
|
||||
|
||||
In [linear algebra](https://en.wikipedia.org/wiki/linear algebra "wp: linear algebra"), [Cramer's rule](https://en.wikipedia.org/wiki/Cramer's rule "wp: Cramer's rule") is an explicit formula for the solution of a [system of linear equations](https://en.wikipedia.org/wiki/system of linear equations "wp: system of linear equations") with as many equations as unknowns, valid whenever the system has a unique solution. It expresses the solution in terms of the determinants of the (square) coefficient matrix and of matrices obtained from it by replacing one column by the vector of right hand sides of the equations.
|
||||
In <a href="https://it.wikipedia.org/wiki/Algebra_lineare"">algebra lineare</a>, la [regola di Cramer](https://it.wikipedia.org/wiki/Regola_di_Cramer "wp: Regola di Cramer") è una formula esplicita per la risoluzione di un [sistema di equazioni lineari](https://it.wikipedia.org/wiki/Sistema_di_equazioni_lineari) con tante soluzioni quante sono le variabili, valida ogni volta che il sistema ha una soluzione unica. Esprime la soluzione in termine di determinanti della matrice quadrata dei coefficienti e delle matrici ottenute da essa sostituendo una delle colonne con il vettore dei termini a destra dell'uguale nelle equazioni.
|
||||
|
||||
Given
|
||||
Dati
|
||||
|
||||
$\\left\\{\\begin{matrix}a_1x + b_1y + c_1z&= {\\color{red}d_1}\\\\a_2x + b_2y + c_2z&= {\\color{red}d_2}\\\\a_3x + b_3y + c_3z&= {\\color{red}d_3}\\end{matrix}\\right.$
|
||||
|
||||
which in matrix format is
|
||||
che in forma matriciale è
|
||||
|
||||
$\\begin{bmatrix} a_1 & b_1 & c_1 \\\\ a_2 & b_2 & c_2 \\\\ a_3 & b_3 & c_3 \\end{bmatrix}\\begin{bmatrix} x \\\\ y \\\\ z \\end{bmatrix}=\\begin{bmatrix} {\\color{red}d_1} \\\\ {\\color{red}d_2} \\\\ {\\color{red}d_3} \\end{bmatrix}.$
|
||||
|
||||
Then the values of $x, y$ and $z$ can be found as follows:
|
||||
Allora i valodi di $x, y$ e $z$ possono essere trovati come segue:
|
||||
|
||||
$x = \\frac{\\begin{vmatrix} {\\color{red}d_1} & b_1 & c_1 \\\\ {\\color{red}d_2} & b_2 & c_2 \\\\ {\\color{red}d_3} & b_3 & c_3 \\end{vmatrix} } { \\begin{vmatrix} a_1 & b_1 & c_1 \\\\ a_2 & b_2 & c_2 \\\\ a_3 & b_3 & c_3 \\end{vmatrix}}, \\quad y = \\frac {\\begin{vmatrix} a_1 & {\\color{red}d_1} & c_1 \\\\ a_2 & {\\color{red}d_2} & c_2 \\\\ a_3 & {\\color{red}d_3} & c_3 \\end{vmatrix}} {\\begin{vmatrix} a_1 & b_1 & c_1 \\\\ a_2 & b_2 & c_2 \\\\ a_3 & b_3 & c_3 \\end{vmatrix}}, \\text{ and }z = \\frac { \\begin{vmatrix} a_1 & b_1 & {\\color{red}d_1} \\\\ a_2 & b_2 & {\\color{red}d_2} \\\\ a_3 & b_3 & {\\color{red}d_3} \\end{vmatrix}} {\\begin{vmatrix} a_1 & b_1 & c_1 \\\\ a_2 & b_2 & c_2 \\\\ a_3 & b_3 & c_3 \\end{vmatrix} }.$
|
||||
|
||||
# --instructions--
|
||||
|
||||
Given the following system of equations:
|
||||
Dato il seguente sistema di equazioni:
|
||||
|
||||
$\\begin{cases} 2w-x+5y+z=-3 \\\\ 3w+2x+2y-6z=-32 \\\\ w+3x+3y-z=-47 \\\\ 5w-2x-3y+3z=49 \\\\ \\end{cases}$
|
||||
|
||||
solve for $w$, $x$, $y$ and $z$, using Cramer's rule.
|
||||
risolvi per $w$, $x$, $y$ e $z$, usando la regola di Cramer.
|
||||
|
||||
# --hints--
|
||||
|
||||
`cramersRule` should be a function.
|
||||
`cramersRule` dovrebbe essere una funzione.
|
||||
|
||||
```js
|
||||
assert(typeof cramersRule === 'function');
|
||||
```
|
||||
|
||||
`cramersRule([[2, -1, 5, 1], [3, 2, 2, -6], [1, 3, 3, -1], [5, -2, -3, 3]], [-3, -32, -47, 49])` should return `[2, -12, -4, 1]`.
|
||||
`cramersRule([[2, -1, 5, 1], [3, 2, 2, -6], [1, 3, 3, -1], [5, -2, -3, 3]], [-3, -32, -47, 49])` dovrebbe restituire `[2, -12, -4, 1]`.
|
||||
|
||||
```js
|
||||
assert.deepEqual(cramersRule(matrices[0], freeTerms[0]), answers[0]);
|
||||
```
|
||||
|
||||
`cramersRule([[3, 1, 1], [2, 2, 5], [1, -3, -4]], [3, -1, 2])` should return `[1, 1, -1]`.
|
||||
`cramersRule([[3, 1, 1], [2, 2, 5], [1, -3, -4]], [3, -1, 2])` dovrebbe restituire `[1, 1, -1]`.
|
||||
|
||||
```js
|
||||
assert.deepEqual(cramersRule(matrices[1], freeTerms[1]), answers[1]);
|
||||
|
@ -8,69 +8,69 @@ dashedName: cusip
|
||||
|
||||
# --description--
|
||||
|
||||
A **CUSIP** is a nine-character alphanumeric code that identifies a North American financial security for the purposes of facilitating clearing and settlement of trades. The CUSIP was adopted as an American National Standard under Accredited Standards X9.6.
|
||||
Il **CUSIP** è un codice alphanumerico lungo 9 carattari che identifica una sicurezza finanziara nord americana con il proposito di facilitare scambi commerciali. Il CUSIP è stato adottato come standard nazionale americano in base agli standard accreditati X9.6.
|
||||
|
||||
# --instructions--
|
||||
|
||||
Write a function that takes a string as a parameter and checks if the string is valid CUSIP.
|
||||
Scrivi una funzione che prende una stringa come parametro e controlla se la stringa è un codice CUSIP valido.
|
||||
|
||||
# --hints--
|
||||
|
||||
`isCusip` should be a function.
|
||||
`isCusip` dovrebbe essere una funzione.
|
||||
|
||||
```js
|
||||
assert(typeof isCusip == 'function');
|
||||
```
|
||||
|
||||
`isCusip("037833100")` should return a boolean.
|
||||
`isCusip("037833100")` dovrebbe restituire un booleano.
|
||||
|
||||
```js
|
||||
assert(typeof isCusip('037833100') == 'boolean');
|
||||
```
|
||||
|
||||
`isCusip("037833100")` should return `true`.
|
||||
`isCusip("037833100")` dovrebbe restituire `true`.
|
||||
|
||||
```js
|
||||
assert.equal(isCusip('037833100'), true);
|
||||
```
|
||||
|
||||
`isCusip("17275R102")` should return `true`.
|
||||
`isCusip("17275R102")` dovrebbe restituire `true`.
|
||||
|
||||
```js
|
||||
assert.equal(isCusip('17275R102'), true);
|
||||
```
|
||||
|
||||
`isCusip("38259P50a")` should return `false`.
|
||||
`isCusip("38259P50a")` dovrebbe restituire `false`.
|
||||
|
||||
```js
|
||||
assert.equal(isCusip('38259P50a'), false);
|
||||
```
|
||||
|
||||
`isCusip("38259P508")` should return `true`.
|
||||
`isCusip("38259P508")` dovrebbe restituire `true`.
|
||||
|
||||
```js
|
||||
assert.equal(isCusip('38259P508'), true);
|
||||
```
|
||||
|
||||
`isCusip("38259P50#")` should return `false`.
|
||||
`isCusip("38259P50#")` dovrebbe restituire `false`.
|
||||
|
||||
```js
|
||||
assert.equal(isCusip('38259P50#'), false);
|
||||
```
|
||||
|
||||
`isCusip("68389X105")` should return `true`.
|
||||
`isCusip("68389X105")` dovrebbe restituire `true`.
|
||||
|
||||
```js
|
||||
assert.equal(isCusip('68389X105'), true);
|
||||
```
|
||||
|
||||
`isCusip("68389X106")` should return `false`.
|
||||
`isCusip("68389X106")` dovrebbe restituire `false`.
|
||||
|
||||
```js
|
||||
assert.equal(isCusip('68389X106'), false);
|
||||
```
|
||||
|
||||
`isCusip("5949181")` should return `false`.
|
||||
`isCusip("5949181")` dovrebbe restituire `false`.
|
||||
|
||||
```js
|
||||
assert.equal(isCusip('5949181'), false);
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 5a23c84252665b21eecc7e06
|
||||
title: Cut a rectangle
|
||||
title: Taglia un rettangolo
|
||||
challengeType: 5
|
||||
forumTopicId: 302242
|
||||
dashedName: cut-a-rectangle
|
||||
@ -8,7 +8,7 @@ dashedName: cut-a-rectangle
|
||||
|
||||
# --description--
|
||||
|
||||
A given rectangle is made from *m* × *n* squares. If *m* and *n* are not both odd, then it is possible to cut a path through the rectangle along the square edges such that the rectangle splits into two connected pieces with the same shape (after rotating one of the pieces by 180°). All such paths for 2 × 2 and 4 × 3 rectangles are shown below.
|
||||
Un rettangolo dato è costituito da *m* × *n* quadrati. Se *m* e *n* non sono entrambi dispari, allora è possibile tagliare un tracciato attraverso il rettangolo lungo i bordi dei quadrati, in modo che il rettangolo si divida in due pezzi collegati con la stessa forma (dopo aver ruotato uno dei pezzi di 180°). Tutti questi percorsi per rettangoli 2 × 2 e 4 × 3 sono riportati di seguito.
|
||||
|
||||
<div style="width: 100%; text-align: center;">
|
||||
<svg xmlns="https://www.w3.org/2000/svg" xmlns:xlink="https://www.w3.org/1999/xlink" width="520" height="170" aria-hidden="true" alt="Diagram showing the possible paths for 2 by 2 and 4 by 3 rectangles">
|
||||
@ -92,47 +92,47 @@ A given rectangle is made from *m* × *n* squares. If *m* and *n* are not both o
|
||||
|
||||
# --instructions--
|
||||
|
||||
Write a function that calculates the number of different ways to cut an *m* × *n* rectangle.
|
||||
Scrivi una funzione che calcola il numero di modi diversi per tagliare un rettangolo *m* × *n*.
|
||||
|
||||
# --hints--
|
||||
|
||||
`cutRectangle` should be a function.
|
||||
`cutRectangle` dovrebbe essere una funzione.
|
||||
|
||||
```js
|
||||
assert(typeof cutRectangle == 'function');
|
||||
```
|
||||
|
||||
`cutRectangle(2, 2)` should return a number.
|
||||
`cutRectangle(2, 2)` dovrebbe restituire un numero.
|
||||
|
||||
```js
|
||||
assert(typeof cutRectangle(2, 2) == 'number');
|
||||
```
|
||||
|
||||
`cutRectangle(2, 2)` should return `2`.
|
||||
`cutRectangle(2, 2)` dovrebbe restituire `2`.
|
||||
|
||||
```js
|
||||
assert.equal(cutRectangle(2, 2), 2);
|
||||
```
|
||||
|
||||
`cutRectangle(4, 3)` should return `9`.
|
||||
`cutRectangle(4, 3)` dovrebbe restituire `9`.
|
||||
|
||||
```js
|
||||
assert.equal(cutRectangle(4, 3), 9);
|
||||
```
|
||||
|
||||
`cutRectangle(4, 4)` should return `22`.
|
||||
`cutRectangle(4, 4)` dovrebbe restituire `22`.
|
||||
|
||||
```js
|
||||
assert.equal(cutRectangle(4, 4), 22);
|
||||
```
|
||||
|
||||
`cutRectangle(8, 3)` should return `53`.
|
||||
`cutRectangle(8, 3)` dovrebbe restituire `53`.
|
||||
|
||||
```js
|
||||
assert.equal(cutRectangle(8, 3), 53);
|
||||
```
|
||||
|
||||
`cutRectangle(7, 4)` should return `151`.
|
||||
`cutRectangle(7, 4)` dovrebbe restituire `151`.
|
||||
|
||||
```js
|
||||
assert.equal(cutRectangle(7, 4), 151);
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 59669d08d75b60482359409f
|
||||
title: Date format
|
||||
title: Formato della data
|
||||
challengeType: 5
|
||||
forumTopicId: 302243
|
||||
dashedName: date-format
|
||||
@ -8,15 +8,15 @@ dashedName: date-format
|
||||
|
||||
# --description--
|
||||
|
||||
Return an array with two date strings of the current date with the following specifications:
|
||||
Restituisci un array con due stringhe data della data corrente con le seguenti specificazioni:
|
||||
|
||||
- The first string's date order should be the year number, month number, and day number separated by dashes (`-`).
|
||||
- The first string's year should be four digits in length.
|
||||
- The first string's month and day should not contain any leading zeros.
|
||||
- The second string's weekday and month names should not be abbreviated.
|
||||
- The second string's day should not contain any leading zeros.
|
||||
- L'ordine della prima stringa dovrebbe essere numero dell'anno, numero del mese, e numero del giorno separati da trattini (`-`).
|
||||
- L'anno della prima stringa dovrebbe avere una lunghezza di quattro cifre.
|
||||
- Il mese e il giorno della prima stringa non dovrebbero avere degli zeri all'inizio.
|
||||
- Il giorno della settimana e del mese nella seconda stringa dovrebbero essere in inglese e non dovrebbero essere abbreviat.
|
||||
- Il giorno della seconda stringa non dovrebbe avere alcuno zero all'inizio.
|
||||
|
||||
Example outputs:
|
||||
Esempi di output:
|
||||
|
||||
```js
|
||||
['2007-11-23', 'Friday, November 23, 2007']
|
||||
@ -25,25 +25,25 @@ Example outputs:
|
||||
|
||||
# --hints--
|
||||
|
||||
`getDateFormats` should be a function.
|
||||
`getDateFormats` dovrebbe essere una funzione.
|
||||
|
||||
```js
|
||||
assert(typeof getDateFormats === 'function');
|
||||
```
|
||||
|
||||
`getDateFormats` should return an object.
|
||||
`getDateFormats` dovrebbe restituire un oggetto.
|
||||
|
||||
```js
|
||||
assert(typeof getDateFormats() === 'object');
|
||||
```
|
||||
|
||||
`getDateFormats` should return an array with 2 elements.
|
||||
`getDateFormats` dovrebbe restituire un array con 2 elementi.
|
||||
|
||||
```js
|
||||
assert(getDateFormats().length === 2);
|
||||
```
|
||||
|
||||
`getDateFormats` should return the correct date in the right format
|
||||
`getDateFormats` dovrebbe restituire la data corretta nel formato giusto
|
||||
|
||||
```js
|
||||
assert.deepEqual(getDateFormats(), dates, equalsMessage);
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 5966c21cf732a95f1b67dd28
|
||||
title: Date manipulation
|
||||
title: Manipolazione delle date
|
||||
challengeType: 5
|
||||
forumTopicId: 302244
|
||||
dashedName: date-manipulation
|
||||
@ -8,27 +8,27 @@ dashedName: date-manipulation
|
||||
|
||||
# --description--
|
||||
|
||||
Given a date string in EST, output the given date as a string with 12 hours added to the time. Time zone should be preserved.
|
||||
Data una data in forma di stringa nel fuso orario EST (UTC-05), restituisci la data come stringa con 12 ore aggiunte all'orario. Il fuso orario deve essere mantenuto.
|
||||
|
||||
Example input: `"March 6 2009 7:30pm EST"`
|
||||
Input di esempio: `"March 6 2009 7:30pm EST"`
|
||||
|
||||
Example output: `"March 7 2009 7:30am EST"`
|
||||
Esempio di output: `"March 7 2009 7:30am EST"`
|
||||
|
||||
# --hints--
|
||||
|
||||
`add12Hours` should be a function.
|
||||
`add12Hours` dovrebbe essere una funzione.
|
||||
|
||||
```js
|
||||
assert(typeof add12Hours === 'function');
|
||||
```
|
||||
|
||||
`add12Hours(dateString)` should return a string.
|
||||
`add12Hours(dateString)` dovrebbe restituire una stringa.
|
||||
|
||||
```js
|
||||
assert(typeof add12Hours('January 17 2017 11:43am EST') === 'string');
|
||||
```
|
||||
|
||||
`add12Hours("January 17 2017 11:43am EST")` should return `"January 17 2017 11:43pm EST"`
|
||||
`add12Hours("January 17 2017 11:43am EST")` dovrebbe restituire `"January 17 2017 11:43pm EST"`
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -36,25 +36,25 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
Should handle day change. `add12Hours("March 6 2009 7:30pm EST")` should return `"March 7 2009 7:30am EST"`
|
||||
Dovrebbe gestire il cambio di giorno. `add12Hours("March 6 2009 7:30pm EST")` dovrebbe restituire `"March 7 2009 7:30am EST"`
|
||||
|
||||
```js
|
||||
assert(add12Hours('March 6 2009 7:30pm EST') === 'March 7 2009 7:30am EST');
|
||||
```
|
||||
|
||||
Should handle month change in a leap years. `add12Hours("February 29 2004 9:15pm EST")` should return `"March 1 2004 9:15am EST"`
|
||||
Dovrebbe gestire il cambio di mese in un anno bisestile. `add12Hours("February 29 2004 9:15pm EST")` dovrebbe restituire `"March 1 2004 9:15am EST"`
|
||||
|
||||
```js
|
||||
assert(add12Hours('February 29 2004 9:15pm EST') === 'March 1 2004 9:15am EST');
|
||||
```
|
||||
|
||||
Should handle month change in a common years. `add12Hours("February 28 1999 3:15pm EST")` should return `"March 1 1999 3:15am EST"`
|
||||
Dovrebbe gestire il cambio di mese in un anno qualsiasi. `add12Hours("February 28 1999 3:15pm EST")` dovrebbe restituire `"March 1 1999 3:15am EST"`
|
||||
|
||||
```js
|
||||
assert(add12Hours('February 28 1999 3:15pm EST') === 'March 1 1999 3:15am EST');
|
||||
```
|
||||
|
||||
Should handle year change. `add12Hours("December 31 2020 1:45pm EST")` should return `"January 1 2021 1:45am EST"`
|
||||
Dovrebbe gestire il cambio di anno. `add12Hours("December 31 2020 1:45pm EST")` dovrebbe restituire `"January 1 2021 1:45am EST"`
|
||||
|
||||
```js
|
||||
assert(
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 5966f99c45e8976909a85575
|
||||
title: Day of the week
|
||||
title: Giorno della settimana
|
||||
challengeType: 5
|
||||
forumTopicId: 302245
|
||||
dashedName: day-of-the-week
|
||||
@ -8,33 +8,33 @@ dashedName: day-of-the-week
|
||||
|
||||
# --description--
|
||||
|
||||
A company decides that whenever Xmas falls on a Sunday they will give their workers all extra paid holidays so that, together with any public holidays, workers will not have to work the following week (between the 25th of December and the first of January).
|
||||
Una azienda decide che ogni volta che Natale capita di domenica daranno ai loro dipendenti abbastanza ferie pagate che assieme ai giorni di vacanza, i dipendenti non dovranno lavorare la settimana seguente (tra il 25 dicembre e il primo gennaio).
|
||||
|
||||
# --instructions--
|
||||
|
||||
Write a function that takes a start year and an end year and return an array of all the years where the 25th of December will be a Sunday.
|
||||
Scrivi una funzione che accetta un anno di inizio e un anno di fine e restituisce un array di tutti gli anni in cui il 25 dicembre cade di domenica.
|
||||
|
||||
# --hints--
|
||||
|
||||
`findXmasSunday` should be a function.
|
||||
`findXmasSunday` dovrebbe essere una funzione.
|
||||
|
||||
```js
|
||||
assert(typeof findXmasSunday === 'function');
|
||||
```
|
||||
|
||||
`findXmasSunday(2000, 2100)` should return an array.
|
||||
`findXmasSunday(2000, 2100)` dovrebbe restituire un array.
|
||||
|
||||
```js
|
||||
assert(typeof findXmasSunday(2000, 2100) === 'object');
|
||||
```
|
||||
|
||||
`findXmasSunday(1970, 2017)` should return `[1977, 1983, 1988, 1994, 2005, 2011, 2016]`
|
||||
`findXmasSunday(1970, 2017)` dovrebbe restituire `[1977, 1983, 1988, 1994, 2005, 2011, 2016]`
|
||||
|
||||
```js
|
||||
assert.deepEqual(findXmasSunday(1970, 2017), firstSolution);
|
||||
```
|
||||
|
||||
`findXmasSunday(2008, 2121)` should return `[2011, 2016, 2022, 2033, 2039, 2044, 2050, 2061, 2067, 2072, 2078, 2089, 2095, 2101, 2107, 2112, 2118]`
|
||||
`findXmasSunday(2008, 2121)` dovrebbe restituire `[2011, 2016, 2022, 2033, 2039, 2044, 2050, 2061, 2067, 2072, 2078, 2089, 2095, 2101, 2107, 2112, 2118]`
|
||||
|
||||
```js
|
||||
assert.deepEqual(findXmasSunday(2008, 2121), secondSolution);
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 59694356a6e7011f7f1c5f4e
|
||||
title: Deal cards for FreeCell
|
||||
title: Dai le carte per FreeCell
|
||||
challengeType: 5
|
||||
forumTopicId: 302246
|
||||
dashedName: deal-cards-for-freecell
|
||||
@ -8,11 +8,11 @@ dashedName: deal-cards-for-freecell
|
||||
|
||||
# --description--
|
||||
|
||||
*FreeCell* is the solitaire card game that Paul Alfille introduced to the PLATO system in 1978. Jim Horne, at Microsoft, changed the name to FreeCell and reimplemented the game for [DOS](https://rosettacode.org/wiki/DOS "DOS"), then [Windows](https://rosettacode.org/wiki/Windows "Windows"). This version introduced 32000 numbered deals.
|
||||
*FreeCell* è il gioco di carte solitario che Paul Alfille ha introdotto nel sistema PLATO nel 1978. Jim Horne, in Microsoft, ha cambiato il nome del gioco a FreeCell e lo ha reimplementato per [DOS](https://rosettacode.org/wiki/DOS "DOS"), e poi per [Windows](https://rosettacode.org/wiki/Windows "Windows"). Questa versione ha introdotto 32000 mani numerate.
|
||||
|
||||
As the game became popular, Jim Horne disclosed the algorithm, and other implementations of FreeCell began to reproduce the Microsoft deals. These deals are numbered from 1 to 32000. Newer versions from Microsoft have 1 million deals, numbered from 1 to 1000000; some implementations allow numbers outside that range.
|
||||
Come il gioco è diventato più popolare, Jim Horne ha rivelato l'algoritmo, e altre implementazioni di FreeCell hanno iniziato a riprodutte le mani di Microsoft. Queste mani sono numerate da 1 a 32000. Versioni più nuove da Microsoft hanno 1 milione di mani, numerate da 1 a 1000000; alcune implementazioni permettono numeri al di fuori di quel range.
|
||||
|
||||
The algorithm uses this [linear congruential generator](https://rosettacode.org/wiki/linear congruential generator "linear congruential generator") from Microsoft C:
|
||||
L'algoritmo usa questo [generatore congruenziale lineare](https://rosettacode.org/wiki/linear congruential generator "linear congruential generator") da Microsoft C:
|
||||
|
||||
<ul>
|
||||
<li>$state_{n + 1} \equiv 214013 \times state_n + 2531011 \pmod{2^{31}}$</li>
|
||||
@ -20,24 +20,24 @@ The algorithm uses this [linear congruential generator](https://rosettacode.org/
|
||||
<li>$rand_n$ is in range 0 to 32767.</li>
|
||||
</ul>
|
||||
|
||||
The algorithm follows:
|
||||
L'algoritmo segue:
|
||||
|
||||
<ol>
|
||||
<li>Seed the RNG with the number of the deal.
|
||||
</li><li>Create an <a href='https://rosettacode.org/wiki/array' title='array' target='_blank'>array</a> of 52 cards: Ace of Clubs, Ace of Diamonds, Ace of Hearts, Ace of Spades, 2 of Clubs, 2 of Diamonds, and so on through the ranks: Ace, 2, 3, 4, 5, 6, 7, 8, 9, 10, Jack, Queen, King. The array indexes are 0 to 51, with Ace of Clubs at 0, and King of Spades at 51.</li>
|
||||
<li>Until the array is empty:</li>
|
||||
<li>Choose a random card at index ≡ next random number (mod array length).</li>
|
||||
<li>Fai il seed del RNG con il numero della mano.
|
||||
</li><li>Crea un <a href='https://rosettacode.org/wiki/array' title='array' target='_blank'>array</a> di 52 carte: asso di fiori, asso di denari, asso di cuori, asso di picche, 2 di fiori, 2 di denari e così via attraverso i semi: asso, 2, 3, 4, 5, 6, 7, 8, 9, 10, Fante, Regina, Re. Gli indici dell'array sono da 0 a 51, con l'asso di fiori a 0, e Re di picche a 51.</li>
|
||||
<li>Fino a quando l'array non è vuoto:</li>
|
||||
<li>Scegli una carta casuale dall'indice ≡ prossimo numero casuale (modulo lunghezza dell'array).</li>
|
||||
<ul>
|
||||
<li>Swap this random card with the last card of the array.</li>
|
||||
<li>Remove this random card from the array. (Array length goes down by 1.)</li>
|
||||
<li>Deal this random card.</li>
|
||||
<li>Scambia questa carta casuale con l'ultima carta dell'array.</li>
|
||||
<li>Rimuovi questa carta casuale dall'array. (La lunghezza dell'array scende di 1.)</li>
|
||||
<li>Distribuisci questa carta casuale.</li>
|
||||
</ul>
|
||||
<li>Deal all 52 cards, face up, across 8 columns. The first 8 cards go in 8 columns, the next 8 cards go on the first 8 cards, and so on.</li>
|
||||
<li>Distribuisci tutte le 52 carte, a faccia in su, su 8 colonne. Le prime 8 carte vanno in 8 colonne, le sucessive 8 carte vanno sulle prime 8 carte, e così via.</li>
|
||||
</ol>
|
||||
|
||||
**Example:**
|
||||
**Per esempio:**
|
||||
|
||||
**Order to deal cards**
|
||||
**Ordine in cui dare le carte**
|
||||
|
||||
<pre> 1 2 3 4 5 6 7 8
|
||||
9 10 11 12 13 14 15 16
|
||||
@ -47,7 +47,7 @@ The algorithm follows:
|
||||
41 42 43 44 45 46 47 48
|
||||
49 50 51 52</pre>
|
||||
|
||||
**Game #1**
|
||||
**Gioco #1**
|
||||
|
||||
```js
|
||||
[
|
||||
@ -61,7 +61,7 @@ The algorithm follows:
|
||||
]
|
||||
```
|
||||
|
||||
**Game #617**
|
||||
**Gioco #617**
|
||||
|
||||
```js
|
||||
[
|
||||
@ -77,37 +77,37 @@ The algorithm follows:
|
||||
|
||||
# --instructions--
|
||||
|
||||
Write a function to take a deal number and deal cards in the same order as this algorithm. The function must return a two dimensional array representing the FreeCell board.
|
||||
Scrivi una funzione che prende un numero di mano e distribuisce le carte nello stesso ordine di questo algoritmo. La funzione deve restituire un array bidimensionale rappresentante il tavolo di FreeCell.
|
||||
|
||||
Deals can also be checked against [FreeCell solutions to 1000000 games](https://freecellgamesolutions.com/). (Summon a video solution, and it displays the initial deal.)
|
||||
Le mani possono anche essere confrontante con [le soluzioni di FreeCell per 1000000 di partite](https://freecellgamesolutions.com/). (Guarda la soluzione video, e mostra la mano iniziale.)
|
||||
|
||||
# --hints--
|
||||
|
||||
`dealFreeCell` should be a function.
|
||||
`dealFreeCell` dovrebbe essere una funzione.
|
||||
|
||||
```js
|
||||
assert(typeof dealFreeCell === 'function');
|
||||
```
|
||||
|
||||
`dealFreeCell(seed)` should return an object.
|
||||
`dealFreeCell(seed)` dovrebbe restituire un oggetto.
|
||||
|
||||
```js
|
||||
assert(typeof dealFreeCell(1) === 'object');
|
||||
```
|
||||
|
||||
`dealFreeCell(seed)` should return an array of length 7.
|
||||
`dealFreeCell(seed)` dovrebbe restituire un array di lunghezza 7.
|
||||
|
||||
```js
|
||||
assert(dealFreeCell(1).length === 7);
|
||||
```
|
||||
|
||||
`dealFreeCell(1)` should return an array identical to example "Game #1"
|
||||
`dealFreeCell(1)` dovrebbe restituire un array identico all'esempio "Game #1"
|
||||
|
||||
```js
|
||||
assert.deepEqual(dealFreeCell(1), game1);
|
||||
```
|
||||
|
||||
`dealFreeCell(617)` should return an array identical to example "Game #617"
|
||||
`dealFreeCell(617)` dovrebbe restituire un array identico all'esempio "Game #617"
|
||||
|
||||
```js
|
||||
assert.deepEqual(dealFreeCell(617), game617);
|
||||
|
@ -8,44 +8,44 @@ dashedName: deepcopy
|
||||
|
||||
# --description--
|
||||
|
||||
Write a function that returns a deep copy of a given object. The copy must not be the same object that was given.
|
||||
Scrivi una funzione che restituisce una copia profonda di un dato oggetto. La copia non deve essere lo stesso oggetto che è stato dato.
|
||||
|
||||
This task will not test for:
|
||||
Questa sfida non testa per:
|
||||
|
||||
<ul>
|
||||
<li>Objects with properties that are functions</li>
|
||||
<li>Date objects or object with properties that are Date objects</li>
|
||||
<li>RegEx or object with properties that are RegEx objects</li>
|
||||
<li>Prototype copying</li>
|
||||
<li>Oggetti con proprietà che sono funzioni</li>
|
||||
<li>Oggetti Date o oggetti con proprietà che sono oggetti Date</li>
|
||||
<li>RegEx o oggetti con proprietà che sono RegEx</li>
|
||||
<li>Copiamento del prototype</li>
|
||||
</ul>
|
||||
|
||||
# --hints--
|
||||
|
||||
`deepcopy` should be a function.
|
||||
`deepcopy` dovrebbe essere una funzione.
|
||||
|
||||
```js
|
||||
assert(typeof deepcopy === 'function');
|
||||
```
|
||||
|
||||
`deepcopy({test: "test"})` should return an object.
|
||||
`deepcopy({test: "test"})` dovrebbe restituire un oggetto.
|
||||
|
||||
```js
|
||||
assert(typeof deepcopy(obj1) === 'object');
|
||||
```
|
||||
|
||||
`deepcopy` should not return the same object that was provided.
|
||||
`deepcopy` non dovrebbe restituire lo stesso oggetto dato.
|
||||
|
||||
```js
|
||||
assert(deepcopy(obj2) != obj2);
|
||||
```
|
||||
|
||||
When passed an object containing an array, `deepcopy` should return a deep copy of the object.
|
||||
Quando gli viene dato un oggetto contenente un array, `deepcopy` dovrebbe restituire una copia profonda dell'oggetto.
|
||||
|
||||
```js
|
||||
assert.deepEqual(deepcopy(obj2), obj2);
|
||||
```
|
||||
|
||||
When passed an object containing another object, `deepcopy` should return a deep copy of the object.
|
||||
Quando gli viene dato un oggetto contenente un altro oggetto, `deepcopy` dovrebbe restituire una copia profonda dell'oggetto.
|
||||
|
||||
```js
|
||||
assert.deepEqual(deepcopy(obj3), obj3);
|
||||
|
@ -45,6 +45,18 @@ assert.deepEqual(uniteUnique([1, 2, 3], [5, 2, 1, 4], [2, 1], [6, 7, 8]), [
|
||||
]);
|
||||
```
|
||||
|
||||
`uniteUnique([1, 3, 2], [5, 4], [5, 6])` should return `[1, 3, 2, 5, 4, 6]`.
|
||||
|
||||
```js
|
||||
assert.deepEqual(uniteUnique([1, 3, 2], [5, 4], [5, 6]), [1, 3, 2, 5, 4, 6]);
|
||||
```
|
||||
|
||||
`uniteUnique([1, 3, 2, 3], [5, 2, 1, 4], [2, 1])` should return `[1, 3, 2, 5, 4]`.
|
||||
|
||||
```js
|
||||
assert.deepEqual(uniteUnique([1, 3, 2, 3], [5, 2, 1, 4], [2, 1]), [1, 3, 2, 5, 4]);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
## --seed-contents--
|
||||
@ -62,7 +74,11 @@ uniteUnique([1, 3, 2], [5, 2, 1, 4], [2, 1]);
|
||||
```js
|
||||
function uniteUnique(arr) {
|
||||
return [].slice.call(arguments).reduce(function(a, b) {
|
||||
return [].concat(a, b.filter(function(e) {return a.indexOf(e) === -1;}));
|
||||
return [].concat(
|
||||
a,
|
||||
b.filter(function(e, currentIndex) {
|
||||
return b.indexOf(e) === currentIndex && a.indexOf(e) === -1;
|
||||
}));
|
||||
}, []);
|
||||
}
|
||||
```
|
||||
|
@ -128,14 +128,15 @@ assert(
|
||||
if (typeof test.remove !== 'function') {
|
||||
return false;
|
||||
}
|
||||
test.add(-1);
|
||||
test.add(1);
|
||||
test.add(4);
|
||||
test.add(3);
|
||||
test.add(7);
|
||||
test.add(16);
|
||||
test.remove(16);
|
||||
test.remove(7);
|
||||
test.add(2);
|
||||
test.add(6);
|
||||
test.add(8);
|
||||
test.remove(6);
|
||||
test.remove(3);
|
||||
return test.inorder().join('') == '-1';
|
||||
return test.inorder().join('') == '1248';
|
||||
})()
|
||||
);
|
||||
```
|
||||
|
@ -128,14 +128,15 @@ assert(
|
||||
if (typeof test.remove !== 'function') {
|
||||
return false;
|
||||
}
|
||||
test.add(-1);
|
||||
test.add(1);
|
||||
test.add(4);
|
||||
test.add(3);
|
||||
test.add(7);
|
||||
test.add(16);
|
||||
test.remove(16);
|
||||
test.remove(7);
|
||||
test.add(2);
|
||||
test.add(6);
|
||||
test.add(8);
|
||||
test.remove(6);
|
||||
test.remove(3);
|
||||
return test.inorder().join('') == '-1';
|
||||
return test.inorder().join('') == '1248';
|
||||
})()
|
||||
);
|
||||
```
|
||||
|
@ -128,14 +128,15 @@ assert(
|
||||
if (typeof test.remove !== 'function') {
|
||||
return false;
|
||||
}
|
||||
test.add(-1);
|
||||
test.add(1);
|
||||
test.add(4);
|
||||
test.add(3);
|
||||
test.add(7);
|
||||
test.add(16);
|
||||
test.remove(16);
|
||||
test.remove(7);
|
||||
test.add(2);
|
||||
test.add(6);
|
||||
test.add(8);
|
||||
test.remove(6);
|
||||
test.remove(3);
|
||||
return test.inorder().join('') == '-1';
|
||||
return test.inorder().join('') == '1248';
|
||||
})()
|
||||
);
|
||||
```
|
||||
|
Reference in New Issue
Block a user