From 6daae6ac9b5d172502b49332a65fd94609f7fbcc Mon Sep 17 00:00:00 2001 From: Francesco-69 Date: Mon, 3 Nov 2025 21:53:24 +0000 Subject: [PATCH 01/35] Master --- it/task-1.md | 35 +++++++++++++++++++++++++++++++++++ it/task-2.md | 30 ++++++++++++++++++++++++++++++ it/task-3.md | 27 +++++++++++++++++++++++++++ it/task-4.md | 34 ++++++++++++++++++++++++++++++++++ 4 files changed, 126 insertions(+) create mode 100644 it/task-1.md create mode 100644 it/task-2.md create mode 100644 it/task-3.md create mode 100644 it/task-4.md diff --git a/it/task-1.md b/it/task-1.md new file mode 100644 index 0000000..fd273bb --- /dev/null +++ b/it/task-1.md @@ -0,0 +1,35 @@ + + +
+ CodeAbbey Monks struggle with bug
+ Artist's impression of programmers struggling with The Bug.
+ Note that proper tools may be helpful! +
+ +Dato che a volte iniziare può essere difficile, proviamo a risolvere il problema più dempilce possibile. +L'obiettivo è fare pratica con l'invio delle risposte, ecc. + +Dobbiamo sommare due numeri e comunicare il risultato. Anche se puoi farlo manualmente, prova a scrivere un programma semplice +in qualsiasi linguaggio tu conosca, ti piaccia o voglia imparare. + +_[**Per favore guarda QUESTO VIDEO da codeabbey author**](https://www.youtube.com/watch?v=c6WWZe12ves) +to get visual demo of writing and submitting solution (as briefly described below)._ + +###Come inviare la soluzione + +Se hai effettuato l'accesso, vedrai i seguenti campi qui sotto: + +- **Test data** contiene "i dati di input" o "casi da testare" - due numeri che dobbiamo sommare. +- **Your answer** - è dove inserisci il risultato dopo aver alaborato i dati. +- **Your solution** - è dove salvi il codice del programma. Non viene controllato + (almeno automaticamente), ma ti aiuterà a riutilizzare il codice nelle attività successive. + Puoi rivedere l'attività in qualsiasi momento per visualizzare la soluzione inviata +Esempio: + + input data: + 3 5 + + soluzione: + 8 +Forniamo **[esempi](../wiki/running)** del programma in diversi linguaggi popolari, +ma ti consigliamo vivamente di non consultarli prima di aver risolto questa attività. :) diff --git a/it/task-2.md b/it/task-2.md new file mode 100644 index 0000000..da5bb7c --- /dev/null +++ b/it/task-2.md @@ -0,0 +1,30 @@ +
+demo of summing an array +
+ +Ora il nostro obiettivo è imparare i **loop** - ovvero le azioni ripetute. +Cerchiamo di calcolare la somma di più numeri (più di due). Sarà utile farlo in un loop. +Come mostrato nell'immagine sopra,puoi creare la variable `sum` e aggiungerci tutti i valori dell'elenco. +Forse il ["for" loop](http://en.wikipedia.org/wiki/For_loop) andrà bene, dato che il numero di valori è noto a priori. + +In caso di problemi, prova prima [Sums In Loop](./sums-in-loop)- probabilmente è più semplice. + +**I dati di input** hanno il seguente formato: + +- la prima linea contiene `N` - quantità di valori da sommare; +- la seconda linea contiene `N` valori veri e propri. + +**La risposta** dovrebbe contenere un singolo valore: la somma di `N` valori. + +Esempio: + + input data: + 8 + 10 20 30 40 5 6 7 8 + + risposta: + 126 + +**Nota** poichè sono presenti diverse decine di numeri, non dovresti copiarli manualmente nel tuo programma. +Fai invece in modo che il tuo programma li legga dallo standard input(dove puoi copiarli tutti insieme). Tieni presente che +se esegui il codice sul nostro server, i dati vengono automaticamente copiati sullo standard input per comodità. diff --git a/it/task-3.md b/it/task-3.md new file mode 100644 index 0000000..eaa6c0c --- /dev/null +++ b/it/task-3.md @@ -0,0 +1,27 @@ +
+ summing two arrays +
+
+ +Se hai già imparato a scrivere un programma con ciclo semplice dal problema [Sum in Loop][prevtask], +questo nuovo esercizio sarà solo una semplice modifica. + +[prevtask]: ./sum-in-loop + +Ora ci vengono fornite diverse coppie di valori e vogliamo calcolare la somma per ciascuna coppia.. + +**Dati di Input** conterranno in numero totale delle coppie da elaborare nella prima riga. +Le righe successive conterranno le coppie da sommare, una coppia per riga. +**Risposta** Dovrebbe contenere i risultati separati da spazi. + +Esempio: + + dati: + 3 + 100 8 + 15 245 + 1945 54 + + risposta: + 108 260 1999 + diff --git a/it/task-4.md b/it/task-4.md new file mode 100644 index 0000000..8811e6c --- /dev/null +++ b/it/task-4.md @@ -0,0 +1,34 @@ +
+ Choosing minimum animation +
+ +La maggior parte dei programmi dovrebbe essere in grado di prendere decisioni. Ora ci eserciteremo con la +programmazione condizionale. +Questo di solito avviene tramite le istruzioni `if ... else` che possono apparire così: + + IF una_condizione THEN + fai_qualcosa + ELSE + fai_altra_cosa + ENDIF + +A seconda del linguaggio di programmazione, la sintassi potrebbe essere diversa e la parte `else` e quasi sempre facoltativa. +Per sapere di più, consulta l'articolo di Wikipedia [Conditional statements][cond]. + +[cond]: http://en.wikipedia.org/wiki/Conditional_(computer_programming) + +tra due numeri, selezionere quallo con il valore minimo. Di seguito diverse coppie per un test approfondito + +**Dait Input** conterranno il numero di casi test nella prima riga. +Le righe successive conterranno una coppia di numeri per il confronto. +Per **Risposta** inserisci lo stesso numero di valori minimi separati da uno spazio, ad esempio: + + dati: + 3 + 5 3 + 2 8 + 100 15 + + risposta: + 3 2 15 + From 901d325da163fe94ba1e78bae175c1f6f0f7d6d6 Mon Sep 17 00:00:00 2001 From: Francesco-69 Date: Mon, 3 Nov 2025 23:38:29 +0100 Subject: [PATCH 02/35] Add files via upload --- it/task-5.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 it/task-5.md diff --git a/it/task-5.md b/it/task-5.md new file mode 100644 index 0000000..2379fe0 --- /dev/null +++ b/it/task-5.md @@ -0,0 +1,20 @@ +Per esercitarci di più con le istruzioni condizionali, scriveremo un programma che utilizza condizioni complesse. +Ovvero un'istruzione `if ... else` potrebbe (e dovrebbe) essere annidata all'interno di altre per risolvere questo problema. + +Verranno fornite diverse terne di numeri. Il vostro compito è selezionare il minimo tra ciascuna. + + +**Dati Input** conterranno nella prima riga il numero di terzine che seguiranno. +Le righe successive conterrano un riga ciascuna. +**Risposta** deve contenere il numero minino della terzina, separato da spazi. + +Esempio: + + data: + 3 + 7 3 5 + 15 20 40 + 300 550 137 + + risposta: + 3 15 137 From 35ca7cba10de5bd1f4a68462650c7340fa86c73c Mon Sep 17 00:00:00 2001 From: Francesco-69 Date: Mon, 3 Nov 2025 23:40:32 +0100 Subject: [PATCH 03/35] Add files via upload --- it/task-15.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 it/task-15.md diff --git a/it/task-15.md b/it/task-15.md new file mode 100644 index 0000000..e890c67 --- /dev/null +++ b/it/task-15.md @@ -0,0 +1,26 @@ +This problem introduces popular algorithm of the "linear search", which should be learnt thoroughly as it is often +used in programming more complex tasks (sorting etc.) + +Very common operation on sequence of values, or arrays is to find its extremal value - maximum or minimum. To achieve +this one need to store **current maximum** (or minimum respectively) in a separate variable, and then run through array, +comparing each of its elements to this variable. Whenever next value is greater than this temporary variable, this +value should be copied into it (as a new maximum). + +At the end of the pass this temporary variable will hold the extremum value. + +**Input data** will give you exactly `300` numbers in a single line. +**Answer** should contain maximum and minimum of these values, separated by space. + +Important: at this problem some people ask **"How should I copy so many numbers at my +code and put commas between, as I create array / list of them..."** +Please, don't do this! Instead [**watch my demo video**](https://www.youtube.com/watch?v=c6WWZe12ves) +(from about 4:00) to see how we use +standard input to read numbers when running on-site! + +**Example:** + + input data: + 1 3 5 7 9 11 ... 295 297 299 300 298 296 ... 12 10 8 6 4 2 + + answer: + 300 1 From c2029403a8a6b85f76090143575e53743db3e5d1 Mon Sep 17 00:00:00 2001 From: Francesco-69 Date: Mon, 3 Nov 2025 23:58:44 +0100 Subject: [PATCH 04/35] Translate task-15.md from English to Italian --- it/task-15.md | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/it/task-15.md b/it/task-15.md index e890c67..1ff7834 100644 --- a/it/task-15.md +++ b/it/task-15.md @@ -1,26 +1,26 @@ -This problem introduces popular algorithm of the "linear search", which should be learnt thoroughly as it is often -used in programming more complex tasks (sorting etc.) +Questo problema introduce il popolare algoritmo della "ricerca lineare" che dovrebbe essere appreso a fondo e come spesso accade +utilizzato nella programmazione di compiti più complessi (ordinamento ecc.). -Very common operation on sequence of values, or arrays is to find its extremal value - maximum or minimum. To achieve -this one need to store **current maximum** (or minimum respectively) in a separate variable, and then run through array, -comparing each of its elements to this variable. Whenever next value is greater than this temporary variable, this -value should be copied into it (as a new maximum). +Operazione molto comune su sequenza di valori, o array è quello di trovare il valore minimo o massimo. Per farlo ho bisogno di +memorizzare **massimo corrente** (o minimo) in una variable, e quindi scorrere attraverso l'array, confrontando ciascun valore +con questa variabile. Ogni volta che il valore successivo è superiore a quello della variabile temporanea questo valore +dovrebbe essere copiato in essa (come nuovo massimo). -At the end of the pass this temporary variable will hold the extremum value. +Alla fine del passaggio questa variabile temporanea manterrà il valore estremo (min o max. -**Input data** will give you exactly `300` numbers in a single line. -**Answer** should contain maximum and minimum of these values, separated by space. +**Dati Input** ti daranno esattamente `300` numeri in una singola riga. +**Risposta** dovrebbe contenere il massimo e il minimo di questi valori, separati da spazio. -Important: at this problem some people ask **"How should I copy so many numbers at my -code and put commas between, as I create array / list of them..."** -Please, don't do this! Instead [**watch my demo video**](https://www.youtube.com/watch?v=c6WWZe12ves) -(from about 4:00) to see how we use -standard input to read numbers when running on-site! +Importante: a questo problema alcuni chiedono **"Come devo copiare tanti numeri nel mio codice, come creo +un array / elenco dei numeri..."** +Ti prego, non fare così! Invece [**Guarda il mio video demo**](https://www.youtube.com/watch?v=c6WWZe12ves) +(dal minuto 4:00) puoi vedere come usiamo lo +standard input per leggere i numeri quando si esegue on-site! -**Example:** +**Esempio:** - input data: + dati di input: 1 3 5 7 9 11 ... 295 297 299 300 298 296 ... 12 10 8 6 4 2 - answer: + risposta: 300 1 From a285ce2ace88f002703a0fb588f0b875c3841085 Mon Sep 17 00:00:00 2001 From: Francesco-69 Date: Tue, 4 Nov 2025 10:04:44 +0100 Subject: [PATCH 05/35] Add files via upload --- it/task-6.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 it/task-6.md diff --git a/it/task-6.md b/it/task-6.md new file mode 100644 index 0000000..3e0f848 --- /dev/null +++ b/it/task-6.md @@ -0,0 +1,28 @@ +When program deals with numbers which have fraction part we sometimes want to **round** such values to whole +integer. We'll need this for programming some later problems (to make answers simpler, for example), so let us +have the following dedicated exercise to learn this trick. + +There are several pairs of numbers. For each pair you are to divide first by second and return +the result, rounded **to the nearest** integer. + +In cases, when result contains exactly `0.5` as a fraction part, value should be rounded "away from zero" +(i.e. by adding another `0.5` to positive or substracting from negative value). +For more thorough explanations, please refer Wikipedia's article on [Rounding - half away from zero](https://en.wikipedia.org/wiki/Rounding#Rounding_half_away_from_zero). + +In any further problems, when rounding is mentioned - just the same rounding algorithm +is supposed (unless other is explicitly specified). + +**Input data** will give a number of test-cases in the first line. +Next lines will contain one test-case (i.e. the pair of numbers) each. +**Answer** should contain division-and-rounding results for each pair, separated with spaces + +Example: + + input data: + 3 + 12 8 + 11 -3 + 400 5 + + answer: + 2 -4 80 From c82a85966d47122a7b219a26f4980b0ee58e00f8 Mon Sep 17 00:00:00 2001 From: Francesco-69 Date: Tue, 4 Nov 2025 10:21:59 +0100 Subject: [PATCH 06/35] Translate task-6.md from English to Italian --- it/task-6.md | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/it/task-6.md b/it/task-6.md index 3e0f848..55abbdf 100644 --- a/it/task-6.md +++ b/it/task-6.md @@ -1,28 +1,27 @@ -When program deals with numbers which have fraction part we sometimes want to **round** such values to whole -integer. We'll need this for programming some later problems (to make answers simpler, for example), so let us -have the following dedicated exercise to learn this trick. +Quando un programma gestisce numeri che hanno una parte frazionaria, a volte vogliamo **arrotondare** a numeri +interi. Questo ci servirà per programmare alcuni problemi successivi (ad esempio per semplificare delle risposte), quindi +svolgiamo il seguente esercizio dedicato per imparare questo trucco. -There are several pairs of numbers. For each pair you are to divide first by second and return -the result, rounded **to the nearest** integer. +Ci sono diverse coppie di numeri. Per ogni coppia devi dividere il primo per il secondo e restituire +il risultato arrotondato all'intero **più vicino**. -In cases, when result contains exactly `0.5` as a fraction part, value should be rounded "away from zero" -(i.e. by adding another `0.5` to positive or substracting from negative value). -For more thorough explanations, please refer Wikipedia's article on [Rounding - half away from zero](https://en.wikipedia.org/wiki/Rounding#Rounding_half_away_from_zero). +Nel caso in cui il risultato contenga esattamente `0.5`, il valore deve essere arrotondato "per eccesso" +(ad esempio aggiungendo `0.5` se positivo o sottraendolo se negativo). +Per spiegazioni approfondite, consultare l'articolo di Wikipedia [Arrotondamento - per eccesso](https://en.wikipedia.org/wiki/Rounding#Rounding_half_away_from_zero). +In qualsiasi altro problema, quando si parla di arrotondamento, si suppone che venga utilizzato lo stesso algoritmo +di arrotondamento (a meno che non venga specificato esplicitamente altro). -In any further problems, when rounding is mentioned - just the same rounding algorithm -is supposed (unless other is explicitly specified). +**Dati Input** forniranno il numero di casi di test nella prima riga. +Le righe successive conterranno un caso di test (ovvero la coppia di numeri) ciascuna. +**Risposta** dovrebbe contenere i risultati della divisione e dell'arrotondamento per ciascuna coppia separati da spazi. -**Input data** will give a number of test-cases in the first line. -Next lines will contain one test-case (i.e. the pair of numbers) each. -**Answer** should contain division-and-rounding results for each pair, separated with spaces +Esempio: -Example: - - input data: + dati input: 3 12 8 11 -3 400 5 - answer: + risposta: 2 -4 80 From 85779774b51dc3d2bf92091d09bc83d7bc16fd95 Mon Sep 17 00:00:00 2001 From: Francesco-69 Date: Tue, 4 Nov 2025 12:02:27 +0100 Subject: [PATCH 07/35] Add files via upload --- it/task-28.md | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 it/task-28.md diff --git a/it/task-28.md b/it/task-28.md new file mode 100644 index 0000000..c7f88a8 --- /dev/null +++ b/it/task-28.md @@ -0,0 +1,39 @@ +Let us apply our programming skills to some quasi-scientific problem - since it is bit dull to learn +only abstract things. + +The simple measure of body constitution was proposed at the middle of XIX century. It depends only on the height and +weight of a person - and is called **Body Mass Index** or **BMI**. It is defined as: + + BMI = weight / height^2 + +Where weight is taken in `kilograms` and height in `meters`. + +Four general grades are proposed: + + Underweight - BMI < 18.5 + Normal weight - 18.5 <= BMI < 25.0 + Overweight - 25.0 <= BMI < 30.0 + Obesity - 30.0 <= BMI + +For example, if I have weight of `80 kg` and height of `1.73 m` I can calculate: + + BMI = 80 / (1.73)^2 = 26.7 + +i.e. somewhat overweight. + +We will not discuss how proper or improper this gradation is. Instead you should simply calculate grades for several +people. + +**Input data** contain number of people in the first line. +Other lines will contain two values each - weight in kilograms and height in metres. +**Answer** should contain words `under`, `normal`, `over`, `obese` for each corresponding test-case, +separated with spaces. For example: + + input data: + 3 + 80 1.73 + 55 1.58 + 49 1.91 + + answer: + over normal under From 2c656f19f866f6bf7772ea3fac9bc4949cd68fd4 Mon Sep 17 00:00:00 2001 From: Francesco-69 Date: Tue, 4 Nov 2025 12:16:16 +0100 Subject: [PATCH 08/35] Translate BMI explanation to Italian --- it/task-28.md | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/it/task-28.md b/it/task-28.md index c7f88a8..2e46003 100644 --- a/it/task-28.md +++ b/it/task-28.md @@ -1,39 +1,40 @@ -Let us apply our programming skills to some quasi-scientific problem - since it is bit dull to learn -only abstract things. +Applicheremo le nostre competenze di programmazione a qualche problema quasi scientifico, - dato che è +un po'noioso imparare solo cose astratte. -The simple measure of body constitution was proposed at the middle of XIX century. It depends only on the height and -weight of a person - and is called **Body Mass Index** or **BMI**. It is defined as: +La semplice misura della costituzione corporea fu proposta a metà del XIX secolo. Dipende solo dall'altezza e +dal peso di una persona - ed è chiamata **Indice di massa corporea** o **BMI**. E' definito come: - BMI = weight / height^2 + BMI = peso / altezza^2 -Where weight is taken in `kilograms` and height in `meters`. +Dove il peso è espresso in `kilogrammi` e l'altezza in `metri`. -Four general grades are proposed: +Sono proposti quattro gradi generali: - Underweight - BMI < 18.5 - Normal weight - 18.5 <= BMI < 25.0 - Overweight - 25.0 <= BMI < 30.0 - Obesity - 30.0 <= BMI + Sottopeso (under) - BMI < 18.5 + Normale (normal) - 18.5 <= BMI < 25.0 + Sovrappeso (over) - 25.0 <= BMI < 30.0 + Obesità (obese) - 30.0 <= BMI -For example, if I have weight of `80 kg` and height of `1.73 m` I can calculate: +Ad esempio, se ho un peso di `80 kg` e un'altezza di `1.73 m` Posso calcolare: BMI = 80 / (1.73)^2 = 26.7 -i.e. somewhat overweight. +ovvero leggermente sovrappeso. -We will not discuss how proper or improper this gradation is. Instead you should simply calculate grades for several -people. +Non discuteremo se questa gradazione sia appropriata o meno. Dovresti semplicemente calcolare i voti per diverse +persone. -**Input data** contain number of people in the first line. -Other lines will contain two values each - weight in kilograms and height in metres. -**Answer** should contain words `under`, `normal`, `over`, `obese` for each corresponding test-case, -separated with spaces. For example: +**Dati Input** contengono il numero delle persone nella prima linea. +Le altre righe conterranno due valori ciascuna - peso in kilogrammi e altezza in metri. +**Risposta** dovrebbe contenere le parole `under`, `normal`, `over`, `obese` per ogni caso di test corrispondente, +separate da spazi. Per esempio: - input data: + dati input: 3 80 1.73 55 1.58 49 1.91 - answer: + risposta: over normal under + From d13433b09e63418cbb39f512fd095f8087229779 Mon Sep 17 00:00:00 2001 From: Francesco-69 Date: Tue, 4 Nov 2025 14:37:33 +0100 Subject: [PATCH 09/35] Add files via upload --- it/task-17.md | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 it/task-17.md diff --git a/it/task-17.md b/it/task-17.md new file mode 100644 index 0000000..8e67269 --- /dev/null +++ b/it/task-17.md @@ -0,0 +1,37 @@ +Checksums are small values calculated from big amount of data to test whether data are consistent, i.e. whether +they contain errors. + +For example if Anna sends some file to Bob, she can calculate its checksum and tell it Bob, who +will calculate checksum on the file he received, and compare it with the value told by Anna. + +_Another, even more common example - any bank card you use has a checksum in the last digit of its number so any +device could prevent you from entering wrong number by mistake (you may read more in the exercise on +[Luhn Algorithm](./luhn-algorithm))._ + +For programming several further tasks we'll use similar way to check whether resulting array is correct or not. To +avoid problems with such tasks let us now practice the checksum calculating algorithm which will be involved. + +###Problem statement + +You will be given the array for which checksum should be calculated. Perform calculation as follows: +for each element of the array (starting from beginning) add this element to `result` variable and multiply this sum by +`113` - this new value taken by modulo `10000007` should become the next value of `result`, and so on. + +Read the [article on checksum](../wiki/checksum) for detailed description of this algorithm. +An example of calculation also could be found there. + +**Input data** will tell the length of an array in the first line. +Array values themselves follow in the second line, separated by spaces. +**Answer** should have a single value - calculated checksum. + +Example: + + input data: + 6 + 3 1 4 1 5 9 + + answer: + 8921379 + +_All input values are between `0` and `1,000,000,000` - be sure to take care of possible overflow in progress of +calculations!_ \ No newline at end of file From fb8d9f2209d6d9fb723ef184108aa2e37e8f974e Mon Sep 17 00:00:00 2001 From: Francesco-69 Date: Tue, 4 Nov 2025 14:57:40 +0100 Subject: [PATCH 10/35] Translate checksum documentation to Italian Translated the checksum explanation and problem statement from English to Italian. --- it/task-17.md | 45 +++++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/it/task-17.md b/it/task-17.md index 8e67269..f59fd19 100644 --- a/it/task-17.md +++ b/it/task-17.md @@ -1,37 +1,38 @@ -Checksums are small values calculated from big amount of data to test whether data are consistent, i.e. whether -they contain errors. +I checksum sono piccoli valori calcolati da una grande quantità di dati, per verificare se i dati sono coerenti +ovvero se contengono errori. -For example if Anna sends some file to Bob, she can calculate its checksum and tell it Bob, who -will calculate checksum on the file he received, and compare it with the value told by Anna. +Ad esempio, se Anna invia un file a Bob, può calcolarne il checksum e comunicarlo a Bob, che +calcolerà il checksum del file ricevuto, e lo confronterà con il valore comunicato da Anna. -_Another, even more common example - any bank card you use has a checksum in the last digit of its number so any -device could prevent you from entering wrong number by mistake (you may read more in the exercise on +_Altro esempio comune - qualsiasi carta di credito che utilizzi ha un checksun nell'ultima cifra del suo numero quindi qualsiasi +dispositivo potrebbe impedirti di inserire un numero errato per errore (puoi approfondire l'argomento nell'esercizio [Luhn Algorithm](./luhn-algorithm))._ -For programming several further tasks we'll use similar way to check whether resulting array is correct or not. To -avoid problems with such tasks let us now practice the checksum calculating algorithm which will be involved. +Per programmare diverse altre attività, utilizzaremo un metodo simile per verificare se l'array è corretto o no. Per +evitare problemi con tali attività, ora esercitiamoci con l'algoritmo di calcolo del checksum che verrà utilizzato. -###Problem statement +###Enunciato del problema -You will be given the array for which checksum should be calculated. Perform calculation as follows: -for each element of the array (starting from beginning) add this element to `result` variable and multiply this sum by -`113` - this new value taken by modulo `10000007` should become the next value of `result`, and so on. +Vi verrà fornito l'array per il quale calcolare il checksum. Eseguite il calcolo come segue: +per ogni elemento dell'array (partendo dall'inizio) aggiungete questo elemento alla variabile `result` e moltiplicate questa somma +per `113` - questo nuovo valore calcolato con modulo `10000007` dovrebbe diventare il nuovo valore di `result`, e così via. -Read the [article on checksum](../wiki/checksum) for detailed description of this algorithm. -An example of calculation also could be found there. +Leggi l' [articolo sul checksum](../wiki/checksum) per un adescrizione dettagliata di questo algoritmo. +Li puoi trovare anche un'esempio di calcolo. -**Input data** will tell the length of an array in the first line. -Array values themselves follow in the second line, separated by spaces. -**Answer** should have a single value - calculated checksum. +**Dati Input** indicheranno la lunghezza di un array nella prima riga. +I valori dell'array seguono nella seconda riga, separati da spazi. +**Risposta** dovrebbe avere un'singolo valore: il checksum calcolato. -Example: +Esempio: - input data: + dati input: 6 3 1 4 1 5 9 - answer: + risposta: 8921379 -_All input values are between `0` and `1,000,000,000` - be sure to take care of possible overflow in progress of -calculations!_ \ No newline at end of file +_Tutti i valori di input sono compresi tra `0` e `1,000,000,000` - assicurarsi di prestare attenzione ai possibili overflow + +durante i calcoli!_ From 6355663f4c1804148960920910e862533260cd25 Mon Sep 17 00:00:00 2001 From: Francesco-69 Date: Tue, 4 Nov 2025 18:20:39 +0100 Subject: [PATCH 11/35] Add files via upload --- it/task-13.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 it/task-13.md diff --git a/it/task-13.md b/it/task-13.md new file mode 100644 index 0000000..043f151 --- /dev/null +++ b/it/task-13.md @@ -0,0 +1,21 @@ +This program resembles more complex algorithms for calculation CRC and other checksums and also hash-functions on +character strings. Besides it will provide you with one more exercise on splitting values to decimal digits. You +may want to try [Sum of Digits](./sum-of-digits) before this one. + +Let us calculate sum of digits, as earlier, but multiplying each digit by its position (counting from the left, starting +from 1). For example, given the value `1776` we calculate such **weighted** sum of digits (let us call it "wsd") as: + + wsd(1776) = 1 * 1 + 7 * 2 + 7 * 3 + 6 * 4 = 60 + +**Input data** will give the number of test-cases in the first line. +Values themselves are in the second line. For each of these values you are to calculate weighted sum of digits. +**Answer:** as usually, put results in one line, separating them with spaces. + +Example: + + input data: + 3 + 9 15 1776 + + answer: + 9 11 60 From b534fbf443c7f24851168681efcbeaa396c1cf4d Mon Sep 17 00:00:00 2001 From: Francesco-69 Date: Tue, 4 Nov 2025 18:32:19 +0100 Subject: [PATCH 12/35] Translate task-13.md to Italian Translated the task description from English to Italian, maintaining the original structure and examples. --- it/task-13.md | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/it/task-13.md b/it/task-13.md index 043f151..4d7e94d 100644 --- a/it/task-13.md +++ b/it/task-13.md @@ -1,21 +1,22 @@ -This program resembles more complex algorithms for calculation CRC and other checksums and also hash-functions on -character strings. Besides it will provide you with one more exercise on splitting values to decimal digits. You -may want to try [Sum of Digits](./sum-of-digits) before this one. +Questo programma assomiglia ad algoritmi più complessi per il calcolo del CRC e di altri checksums nonchè a funzioni hash su +stringhe di caratteri. Inoltre fornisce un ulteriore esercizio sulla suddivisione dei valori in cifre decimali. Potresti +provare [Somma delle Cifre](./sum-of-digits) prima di questo. -Let us calculate sum of digits, as earlier, but multiplying each digit by its position (counting from the left, starting -from 1). For example, given the value `1776` we calculate such **weighted** sum of digits (let us call it "wsd") as: +Calcoliamo la somma delle cifre, come in precedenza, moltiplicando ogni cifra per la sua posizione (contando da sinistra a destra +partendo da 1). Ad esempio, dato il valore `1776` calcoliamo la somma **ponderata** delle cifre (chiamiamola "wsd") come segue: wsd(1776) = 1 * 1 + 7 * 2 + 7 * 3 + 6 * 4 = 60 -**Input data** will give the number of test-cases in the first line. -Values themselves are in the second line. For each of these values you are to calculate weighted sum of digits. -**Answer:** as usually, put results in one line, separating them with spaces. +**Dati di Input** fornirà il numero di test nella prima riga. +I valori veri si trovano nella seconda riga. Per ciascuno di questi valori si deve calcolare la somma ponderata delle cifre. +**Risposta:** come di consueto, Inserire i risultati su una riga, separandoli con spazi. Example: - input data: + dati input: 3 9 15 1776 - answer: + risposta: 9 11 60 + From 4db3342bf4bf0ac6fc086523a419907965f4b70e Mon Sep 17 00:00:00 2001 From: Francesco-69 Date: Wed, 5 Nov 2025 15:47:51 +0100 Subject: [PATCH 13/35] Add files via upload --- it/task.478.md | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 it/task.478.md diff --git a/it/task.478.md b/it/task.478.md new file mode 100644 index 0000000..13e9a4c --- /dev/null +++ b/it/task.478.md @@ -0,0 +1,35 @@ +_This problem was kindly created for us by [**Clive Fraser**](/index/user_profile/csfpython) - many thanks!_ + +Alfie the robot works in a large factory complex. The complex is a square of side 5 km. Alfie's job is to collect partially or completely finished items from one collection/delivery point in the complex and to deliver them to another point. The factory complex has a number of lanes running parallel to the sides of the square; one set going from east to west and the other from north to south. So these lanes always cross each other at right angles. The lanes run above the working area of the factory so that Alfie can move without interfering with any of the work areas. The collection/delivery points are all placed at intersections of the two sets of lanes. Alfie will always choose the shortest distance between two points but is constrained to follow the lanes; so he must always be travelling parallel to one of the edges of the square. The collection/delivery points are distinguished by their (x,y) coordinates, where x and y are the distances (in metres) east and south respectively, of one of the corners of the square which has the coordinates (0,0). + +Alfie has his docking station at the point (0,0). When at the docking station, Alfie is sent a list of deliveries which he has to make. Each of these gives the coordinates of the collection/delivery point where he is to pick up a package, and the coordinates of the point where the package is to be delivered. In order to improve efficiency, each delivery is sent in a standard sized crate. There may be many items inside the crate but Alfie regards a crate as a single delivery. If a collection/delivery point needs to send multiple crates to the same destination, each of these has to be listed as a separate delivery. Alfie is designed to be able to carry two crates (at most) at any one time. + +When Alfie gets a list of deliveries he uses a specially designed software package to work out the optimum route for the collection and delivery of all of the crates. The route takes him from his docking station, through all of the collections and deliveries and then back to the docking station. The software ensures that Alfie will never need to be carrying more than 2 crates. The software also ensures that the total distance travelled by Alfie is a minimum. + +In this problem you will be given a delivery list for Alfie and are asked to find the distance travelled by Alfie in making all of the deliveries, after starting from the docking station and finally returning to the docking station. + +The first line of the problem will be a single integer N denoting the number of collections and deliveries to be made. Each of the following N lines will consist of four integers X1, Y1, X2 and Y2, separated by spaces. (X1,Y1) gives the location of the point from which a crate needs to be collected. (X2,Y2) gives the location of the point where the same crate needs to be delivered. Your answer is the length (in metres) of the optimum route taken by Alfie in completing the list of deliveries and returning to the docking station. + +The Example below has N = 3, so there are 3 crates to be collected and delivered. The optimum route has a length of 18206 metres and is executed as described in the following table. (Note that Crates Carried refers to the number of crates being carried by Alfie, after reaching the given location) + + Location Total Distance Crates Carried + + (0,0) 0 0 Start at docking station + (737,482) 1219 1 Collect crate number 2 + (3855,4069) 7924 2 Collect crate number 1 + (4230,4175) 8405 1 Deliver crate number 2 + (4837,3926) 9261 2 Collect crate number 3 + (2127,1979) 13918 1 Deliver crate number 3 + (1542,2070) 14594 0 Deliver crate number 1 + (0,0) 18206 0 Return to docking station + +Example: + + input: + 3 + 3855 4069 1542 2070 + 737 482 4230 4175 + 4837 3926 2127 1979 + + answer: + 18206 \ No newline at end of file From 9c63367f63719c0f23cc362ca51220fb91ff5d3f Mon Sep 17 00:00:00 2001 From: Francesco-69 Date: Wed, 5 Nov 2025 15:54:07 +0100 Subject: [PATCH 14/35] Translate task description to Italian Translated the problem description and example from English to Italian. --- it/task.478.md | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/it/task.478.md b/it/task.478.md index 13e9a4c..7932e98 100644 --- a/it/task.478.md +++ b/it/task.478.md @@ -1,29 +1,31 @@ -_This problem was kindly created for us by [**Clive Fraser**](/index/user_profile/csfpython) - many thanks!_ +_Questo problema è stato gentilmente creato da [**Clive Fraser**](/index/user_profile/csfpython) - many thanks!_ -Alfie the robot works in a large factory complex. The complex is a square of side 5 km. Alfie's job is to collect partially or completely finished items from one collection/delivery point in the complex and to deliver them to another point. The factory complex has a number of lanes running parallel to the sides of the square; one set going from east to west and the other from north to south. So these lanes always cross each other at right angles. The lanes run above the working area of the factory so that Alfie can move without interfering with any of the work areas. The collection/delivery points are all placed at intersections of the two sets of lanes. Alfie will always choose the shortest distance between two points but is constrained to follow the lanes; so he must always be travelling parallel to one of the edges of the square. The collection/delivery points are distinguished by their (x,y) coordinates, where x and y are the distances (in metres) east and south respectively, of one of the corners of the square which has the coordinates (0,0). +Il robot Alfie lavora in un grande complesso industriale. Il complesso è un quadrato di 5 km di lato. Il compito di Alfie è quello di raccogliere articoli parzialmente o completamente finiti da un punto di raccolta/consegna del complesso e di consegnarli a un altro punto. Il complesso industriale ha diverse corsie che corrono parallele ai lati del quadrato: una da est a ovest e l'altra da nord a sud. Quindi queste corsie si incrociano sempre ad angolo retto. Le corsie corrono sopra l'area di lavoro della fabbrica in modo che Alfie possa muoversi senza interferire con nessuna delle aree di lavoro. I punti di raccolta/consegna sono tutti posizionati all'intersezione dei due insiemi di corsie. Alfie sceglierà sempre la distanza più breve tra due punti, ma è vincolato a seguire le corsie; quindi deve sempre viaggiare parallelamente a uno dei bordi del quadrato. I punti di ritiro/consegna sono distinti dalle loro coordinate (x,y), dove x e y sono rispettivamente le distanze (in metri) a est e a sud di uno degli angoli del quadrato che ha coordinate (0,0). -Alfie has his docking station at the point (0,0). When at the docking station, Alfie is sent a list of deliveries which he has to make. Each of these gives the coordinates of the collection/delivery point where he is to pick up a package, and the coordinates of the point where the package is to be delivered. In order to improve efficiency, each delivery is sent in a standard sized crate. There may be many items inside the crate but Alfie regards a crate as a single delivery. If a collection/delivery point needs to send multiple crates to the same destination, each of these has to be listed as a separate delivery. Alfie is designed to be able to carry two crates (at most) at any one time. +Alfie ha la sua stazione di attracco nel punto (0,0). Una volta arrivato alla stazione di attracco, ad Alfie viene inviato un elenco delle consegne da effettuare. Ognuna di queste indica le coordinate del punto di ritiro/consegna in cui deve ritirare un pacco e le coordinate del punto in cui il pacco deve essere consegnato. Per migliorare l'efficienza, ogni consegna viene spedita in una cassa di dimensioni standard. All'interno della cassa possono esserci molti articoli, ma Alfie considera una cassa come un'unica consegna. Se un punto di ritiro/consegna deve inviare più casse alla stessa destinazione, ciascuna di queste deve essere elencata come una consegna separata. Alfie è progettato per poter trasportare due casse (al massimo) contemporaneamente. When Alfie gets a list of deliveries he uses a specially designed software package to work out the optimum route for the collection and delivery of all of the crates. The route takes him from his docking station, through all of the collections and deliveries and then back to the docking station. The software ensures that Alfie will never need to be carrying more than 2 crates. The software also ensures that the total distance travelled by Alfie is a minimum. -In this problem you will be given a delivery list for Alfie and are asked to find the distance travelled by Alfie in making all of the deliveries, after starting from the docking station and finally returning to the docking station. +Quando Alfie riceve un elenco delle consegne, utilizza un software appositamente progettato per calcolare il percorso ottimale per il ritiro e la consegna di tutte le casse. Il percorso lo porta dalla sua stazione di attracco, attraverso tutti i ritiri e le consegne, per poi tornare alla stazione di attracco. Il software garantisce che Alfie non debba mai trasportare più di 2 casse. Il software garantisce inoltre che la distanza totale percorsa da Alfie sia minima. -The first line of the problem will be a single integer N denoting the number of collections and deliveries to be made. Each of the following N lines will consist of four integers X1, Y1, X2 and Y2, separated by spaces. (X1,Y1) gives the location of the point from which a crate needs to be collected. (X2,Y2) gives the location of the point where the same crate needs to be delivered. Your answer is the length (in metres) of the optimum route taken by Alfie in completing the list of deliveries and returning to the docking station. +In questo problema ti verrà fornito un elenco delle consegne per Alfie e ti verrà chiesto di calcolare la distanza percorsa da Alfie per effettuare tutte le consegne, partendo dalla stazione di attracco e tornandovi. -The Example below has N = 3, so there are 3 crates to be collected and delivered. The optimum route has a length of 18206 metres and is executed as described in the following table. (Note that Crates Carried refers to the number of crates being carried by Alfie, after reaching the given location) +La prima riga del problema sarà un singolo intero N che indica il numero di ritiri e consegne da effettuare. Ciascuna delle successive N righe sarà composta da quattro interi X1, Y1, X2 e Y2, separati da spazi. (X1,Y1) indica la posizione del punto da cui deve essere ritirata una cassa. (X2,Y2) indica la posizione del punto in cui la stessa cassa deve essere consegnata. Il risultato è la lunghezza (in metri) del percorso ottimale seguito da Alfie per completare l'elenco delle consegne e tornare alla stazione di attracco. - Location Total Distance Crates Carried +Nell'esempio seguente, N = 3, quindi ci sono 3 casse da ritirare e consegnare. Il percorso ottimale ha una lunghezza di 18206 metri e viene eseguito come descritto nella tabella seguente. (Nota che le casse trasportate si riferiscono al numero di casse trasportate da Alfie, dopo aver raggiunto la posizione indicata) + + Posizione Distanza Totale Colli trasportati - (0,0) 0 0 Start at docking station - (737,482) 1219 1 Collect crate number 2 - (3855,4069) 7924 2 Collect crate number 1 - (4230,4175) 8405 1 Deliver crate number 2 - (4837,3926) 9261 2 Collect crate number 3 - (2127,1979) 13918 1 Deliver crate number 3 - (1542,2070) 14594 0 Deliver crate number 1 - (0,0) 18206 0 Return to docking station + (0,0) 0 0 Inizia alla stazione di attracco + (737,482) 1219 1 Raccogli la cassa numero 2 + (3855,4069) 7924 2 Raccogli la cassa numero 1 + (4230,4175) 8405 1 Consegna la cassa numero 2 + (4837,3926) 9261 2 Raccogli la cassa numero 3 + (2127,1979) 13918 1 Consegna la cassa numero 3 + (1542,2070) 14594 0 Consegna la cassa numero 1 + (0,0) 18206 0 Ritorna alla stazione di attracco -Example: +Esempio: input: 3 @@ -31,5 +33,5 @@ Example: 737 482 4230 4175 4837 3926 2127 1979 - answer: - 18206 \ No newline at end of file + risposta: + 18206 From 92cecd305ab5fd8911aefa5dc05cdac54add30d4 Mon Sep 17 00:00:00 2001 From: Francesco-69 Date: Sun, 9 Nov 2025 09:14:17 +0100 Subject: [PATCH 15/35] Add files via upload --- it/task-36.md | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 it/task-36.md diff --git a/it/task-36.md b/it/task-36.md new file mode 100644 index 0000000..2e2722b --- /dev/null +++ b/it/task-36.md @@ -0,0 +1,44 @@ + +If you know the old game [Bulls and Cows](./bulls-and-cows), this programming problem will look familiar to you. + +Andrew and Peter play the code-guessing game. Andrew chooses a `secret number` consisting of `3` digits. Peter tries to +guess it, proposing several values, one by one. + +For each `guess` Andrew should answer how many digits are correct - i.e. **are the same** in the proposed value and in his +secret number - and are placed in **the same position**. For example, if secret number is `125` and Peter calls `523`, then +Andrew answers with `1`. Here is the sample of the game: + + Andrew chooses a secret number 846 + + Peter's guess Andrew's answer + 402 0 + 390 0 + 816 2 + 848 2 + 777 0 + 815 1 + 846 3 + +So Peter have guessed correct number after `6` attempts. + +You are to write program which reads guesses given by Peter (except the last) and prints out the secret number +choosen by Andrew. It is guaranteed that exactly one solution exists. + +**Input data** will contain number of guesses in the first line. +Then answers with attempts will follow - each contains the number told by Peter and the answer given by Andrew. +In contrast with examples numbers will be of `4` digits. +**Answer** should contain the secret number (also `4` digits). See example: + + input data: + 6 + 402 0 + 390 0 + 816 2 + 848 2 + 777 0 + 815 1 + + answer: + 846 + +*Here we use 3-digit values for brevity, but the algorithm is the same.* \ No newline at end of file From f8c429a2e5a1ce76d6de490c1f208bcf9752a5f3 Mon Sep 17 00:00:00 2001 From: Francesco-69 Date: Sun, 9 Nov 2025 09:24:32 +0100 Subject: [PATCH 16/35] Translate Code Guesser to Italian and update examples Translated the code guesser problem description from English to Italian and updated the example to use 4-digit numbers. --- it/task-36.md | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/it/task-36.md b/it/task-36.md index 2e2722b..3a09d66 100644 --- a/it/task-36.md +++ b/it/task-36.md @@ -1,16 +1,16 @@ -If you know the old game [Bulls and Cows](./bulls-and-cows), this programming problem will look familiar to you. +Se conoscete il vecchio gioco [Bulls and Cows](./bulls-and-cows), questo problema di programmazione vi sembrerà familiare. -Andrew and Peter play the code-guessing game. Andrew chooses a `secret number` consisting of `3` digits. Peter tries to -guess it, proposing several values, one by one. +Andrew e Peter giocano a indovinare il codice. Andrew sceglie un `numero segreto` composto da `3` cifre. Peter cerca di +indovinarlo, proponendo diversi valori, uno alla volta. -For each `guess` Andrew should answer how many digits are correct - i.e. **are the same** in the proposed value and in his -secret number - and are placed in **the same position**. For example, if secret number is `125` and Peter calls `523`, then -Andrew answers with `1`. Here is the sample of the game: +Per ogni `ipotesi` Andrew deve dire quante cifre sono corrette, ovvero **sono le stesse** nel valore proposto e nel suo +numero segreto, e sono posizionate nella **stessa posizione**. Ad esempio, se il numero segreto è `125` e Peter dice `523`, allora +Andrew risponde con `1`. Ecco un esempio del gioco: - Andrew chooses a secret number 846 + Andrea sceglie un numero segreto: 846 - Peter's guess Andrew's answer + Ipotesi diPeter Risposta diAndrew 402 0 390 0 816 2 @@ -19,17 +19,17 @@ Andrew answers with `1`. Here is the sample of the game: 815 1 846 3 -So Peter have guessed correct number after `6` attempts. +Quindi Peter ha indovinato il numero corretto dopo `6` tentativi. -You are to write program which reads guesses given by Peter (except the last) and prints out the secret number -choosen by Andrew. It is guaranteed that exactly one solution exists. +Devi scrivere un programma che legga le ipotesi fornite da Peter (tranne l'ultima) e stampi il numero segreto +scelto da Andrew. È garantito che esista esattamente una soluzione. -**Input data** will contain number of guesses in the first line. -Then answers with attempts will follow - each contains the number told by Peter and the answer given by Andrew. -In contrast with examples numbers will be of `4` digits. -**Answer** should contain the secret number (also `4` digits). See example: +I **dati di input** conterranno il numero di ipotesi nella prima riga. +Seguiranno poi le risposte con i relativi tentativi, ciascuna contenente il numero fornito da Peter e la risposta data da Andrew. +A differenza degli esempi, i numeri saranno composti da `4` cifre. +La **risposta** dovrebbe contenere il numero segreto (anch'esso di `4` cifre). Vedi esempio: - input data: + dat input: 6 402 0 390 0 @@ -38,7 +38,8 @@ In contrast with examples numbers will be of `4` digits. 777 0 815 1 - answer: + risposta: 846 -*Here we use 3-digit values for brevity, but the algorithm is the same.* \ No newline at end of file + +*Here we use 3-digit values for brevity, but the algorithm is the same.* From 8ba8272ac06c630e2f9a295da4ff1daf9661f0e9 Mon Sep 17 00:00:00 2001 From: Francesco-69 Date: Sun, 9 Nov 2025 09:27:35 +0100 Subject: [PATCH 17/35] Update task description for Code Guesser --- it/task-36.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/it/task-36.md b/it/task-36.md index 3a09d66..459a4f3 100644 --- a/it/task-36.md +++ b/it/task-36.md @@ -42,4 +42,5 @@ La **risposta** dovrebbe contenere il numero segreto (anch'esso di `4` cifre). V 846 -*Here we use 3-digit values for brevity, but the algorithm is the same.* +*Qui utilizziamo valori a 3 cifre per brevità, ma l'algoritmo è lo stesso.* + From cf0de068f7738091aa96b3de2625e0b5b1a9eb21 Mon Sep 17 00:00:00 2001 From: Francesco-69 Date: Tue, 18 Nov 2025 09:19:30 +0100 Subject: [PATCH 18/35] Add files via upload --- it/task-39.md | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 it/task-39.md diff --git a/it/task-39.md b/it/task-39.md new file mode 100644 index 0000000..fa7f8af --- /dev/null +++ b/it/task-39.md @@ -0,0 +1,42 @@ + +Prolific trader Paul Penniless wants to be millionaire. He is trying to buy or sell shares and make profit on the +changing prices. I.e. if he is lucky to buy `200` shares for `20` dounds apiece and sell in a week for `23`, he gains +`600` dounds in just few days. + +Paul read an article on [Standard Deviation](../wiki/standard-deviation) and has the new idea now. He at once realized +that the main problem is that the broker (the company who provides service for playing at market) takes comission of +`1%` for each deal. So regarding example above Paul loses `40` dounds when buying shares and `46` more when selling them +back. So the real profit is not `600` but only `600 - 40 - 46 = 514` dounds. + +It is obvious for him now, that he should prefer operations with shares which are more **volatile** - i.e. the price of +which changes in wider range, so that his profit from changing price is more significant when compared to broker's +comission. + +For example, if initial price of shares was `50` (rather than `20`) and it had grown to `52` when Paul sold them, his +profit for `200` shares would be only `400` dounds. However, comission would be `100` dounds when buying and `104` +when selling, so his real gain is only `196` dounds - more than half money was taken by broker! + +Paul decided that he will choose whether to deal with shares of some kind or not depending on the following rule: +standard deviation of prices for these shares over the last fortnight should be at least **four times greater** than +broker's comission (which is `1%`), i.e. for share with mean price `50` comission is `0.5` and standard deviation +should be equal or greater than `2`. + +For example if the price was `99` dounds for `7` days and `101` for other `7` days, then the average price is `100`, +and broker comission (per share) is `1` dound. Standard deviation would be `1` dound also, so these shares do not +deserve being bought or sold. + +**Input data** will contain number of stocks (share types or names) for which calculations should be done. +Next lines contain descriptions of stock - the stock name (four latin letters) and then `14` values - prices for +each day over last fortnight. +**Answer** should contain names of stocks which are volatile enough by Paul's criteria (in the same order as they +were given in the input). + +Example: + + input data: + 2 + JOOG 99 99 99 99 99 99 99 101 101 101 101 101 101 101 + GOLD 95 105 95 105 95 105 95 105 95 105 95 105 95 105 + + answer: + GOLD From 1a174cfcaeeb716b6d5631f91e93d2e2a829f8ad Mon Sep 17 00:00:00 2001 From: Francesco-69 Date: Tue, 18 Nov 2025 09:30:57 +0100 Subject: [PATCH 19/35] Translate task-39.md to Italian Translated the task description from English to Italian, ensuring clarity in the explanation of standard deviation and trading strategies. --- it/task-39.md | 56 +++++++++++++++++++++++++-------------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/it/task-39.md b/it/task-39.md index fa7f8af..0407dcb 100644 --- a/it/task-39.md +++ b/it/task-39.md @@ -1,42 +1,42 @@ -Prolific trader Paul Penniless wants to be millionaire. He is trying to buy or sell shares and make profit on the -changing prices. I.e. if he is lucky to buy `200` shares for `20` dounds apiece and sell in a week for `23`, he gains -`600` dounds in just few days. +Il prolifico trader Paul Penniless vuole diventare milionario. Cerca di acquistare o vendere azioni e trarre profitto dalle +variazioni dei prezzi. Ad esempio, se è fortunato ad acquistare `200` azioni a `20` dounds l'una e a rivenderle in una settimana a `23`, +guadagna `600` dounds in pochi giorni. -Paul read an article on [Standard Deviation](../wiki/standard-deviation) and has the new idea now. He at once realized -that the main problem is that the broker (the company who provides service for playing at market) takes comission of -`1%` for each deal. So regarding example above Paul loses `40` dounds when buying shares and `46` more when selling them -back. So the real profit is not `600` but only `600 - 40 - 46 = 514` dounds. +Paul ha letto un'articolo sulla [Standard Deviation](../wiki/standard-deviation) e ora ha una nuova idea. Ha subito capito +che il problema principale è che il broker (la società che fornisce servizi per giocare al mercato) prende una commissione dell' +1% per ogni operazione. Quindi, nell'esempio precedente, Paul perde 40` dounds quando acquista azioni e altri 46` quando le rivende. +Quindi il profitto reale non è 600`, ma solo 600 - 40 - 46 = 514` dounds. -It is obvious for him now, that he should prefer operations with shares which are more **volatile** - i.e. the price of -which changes in wider range, so that his profit from changing price is more significant when compared to broker's -comission. +Ora è ovvio per lui che dovrebbe preferire operazioni con azioni più **volatili**, ovvero il cui prezzo +cambia in un intervallo più ampio, in modo che il suo profitto derivante dalle variazioni di prezzo sia più significativo +ispetto alla commissione del broker. -For example, if initial price of shares was `50` (rather than `20`) and it had grown to `52` when Paul sold them, his -profit for `200` shares would be only `400` dounds. However, comission would be `100` dounds when buying and `104` -when selling, so his real gain is only `196` dounds - more than half money was taken by broker! +Ad esempio, se il prezzo iniziale delle azioni fosse stato di `50` (anziché `20`) e fosse salito a `52` quando Paul le ha vendute, il suo +profitto per `200` azioni sarebbe stato di soli `400` dound. Tuttavia, la commissione sarebbe stata di `100` dound all'acquisto e di `104` +dound alla vendita, quindi il suo guadagno reale sarebbe stato di soli `196` dound: più della metà del denaro è stata incassata dal broker! -Paul decided that he will choose whether to deal with shares of some kind or not depending on the following rule: -standard deviation of prices for these shares over the last fortnight should be at least **four times greater** than -broker's comission (which is `1%`), i.e. for share with mean price `50` comission is `0.5` and standard deviation -should be equal or greater than `2`. +Paul ha deciso che avrebbe scelto se negoziare o meno azioni di un certo tipo in base alla seguente regola: +la deviazione standard dei prezzi di queste azioni nelle ultime due settimane dovrebbe essere almeno **quattro volte maggiore** della +commissione del broker (che è `1%`), ovvero per un'azione con prezzo medio `50` la commissione è `0,5` e la deviazione standard +dovrebbe essere uguale o maggiore di `2`. -For example if the price was `99` dounds for `7` days and `101` for other `7` days, then the average price is `100`, -and broker comission (per share) is `1` dound. Standard deviation would be `1` dound also, so these shares do not -deserve being bought or sold. +Ad esempio, se il prezzo era `99` dound per `7` giorni e `101` per gli altri `7` giorni, il prezzo medio è `100`, +e la commissione di intermediazione (per azione) è `1` dound. Anche la deviazione standard sarebbe `1` dound, quindi queste azioni non +meritano di essere acquistate o vendute. -**Input data** will contain number of stocks (share types or names) for which calculations should be done. -Next lines contain descriptions of stock - the stock name (four latin letters) and then `14` values - prices for -each day over last fortnight. -**Answer** should contain names of stocks which are volatile enough by Paul's criteria (in the same order as they -were given in the input). +**I dati di input** conterranno il numero di azioni (tipi o nomi di azioni) per cui devono essere eseguiti i calcoli. +Le righe successive contengono le descrizioni delle azioni - il nome dell'azione (quattro lettere latine) e poi i valori `14` - i prezzi per +ogni giorno nelle ultime due settimane. +**La risposta** dovrebbe contenere i nomi delle azioni che sono sufficientemente volatili secondo i criteri di Paul (nello stesso ordine in cui +sono state fornite nell'input). -Example: +Esempio: - input data: + dati input: 2 JOOG 99 99 99 99 99 99 99 101 101 101 101 101 101 101 GOLD 95 105 95 105 95 105 95 105 95 105 95 105 95 105 - answer: + risposta: GOLD From b2d7cf2a0c4b4925b92cb6c88141ebbb12dd35ab Mon Sep 17 00:00:00 2001 From: Francesco-69 Date: Tue, 18 Nov 2025 09:32:38 +0100 Subject: [PATCH 20/35] Add files via upload --- it/task-7.md | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 it/task-7.md diff --git a/it/task-7.md b/it/task-7.md new file mode 100644 index 0000000..da1e975 --- /dev/null +++ b/it/task-7.md @@ -0,0 +1,31 @@ + +This programming exercise is roughly the same as counting sums in loop, but it needs bit more calculations. + +
+ fahrenheit and celsius +
+ +*Note: the problem [Rounding](./rounding) explains the rounding algorithm which is used in this task.* + +There are two widespread systems of measuring temperature - Celsius and Fahrenheit. First is quite popular in Europe +and second is well in use in United States for example. + +By Celsius scale water freezes at 0 degrees and boils at 100 degrees. By Fahrenheit water freezes +at 32 degrees and boils at 212 degrees. You may learn more from [wikipedia on Fahrenheit][wiki]. Use these two points +for conversion of other temperatures. + +[wiki]: http://en.wikipedia.org/wiki/Fahrenheit + +You are to write program to convert degrees of Fahrenheit to Celsius. + +**Input data** contains `N+1` values, first of them is `N` itself (**Note** that you should not try to convert it). +**Answer** should contain exactly `N` results, rounded to nearest integer and separated by spaces. + +Example: + + data: + 5 495 353 168 -39 22 + answer: + 257 178 76 -39 -6 + +*Please note that first `5` is not a temperature, but the amount of values to convert!* \ No newline at end of file From 55df116e6464924ce4b9aee0a6bd551f718e01ab Mon Sep 17 00:00:00 2001 From: Francesco-69 Date: Tue, 18 Nov 2025 09:37:34 +0100 Subject: [PATCH 21/35] Translate Fahrenheit to Celsius task to Italian --- it/task-7.md | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/it/task-7.md b/it/task-7.md index da1e975..e1ddb1e 100644 --- a/it/task-7.md +++ b/it/task-7.md @@ -1,31 +1,32 @@ -This programming exercise is roughly the same as counting sums in loop, but it needs bit more calculations. +Questo esercizio di programmazione è più o meno lo stesso del conteggio delle somme in un ciclo, ma richiede qualche calcolo in più.
fahrenheit and celsius
-*Note: the problem [Rounding](./rounding) explains the rounding algorithm which is used in this task.* +*Nota: il problema [Rounding](./rounding) spiega l'algoritmo di arrotondamento utilizzato in questa attività.* -There are two widespread systems of measuring temperature - Celsius and Fahrenheit. First is quite popular in Europe -and second is well in use in United States for example. +Esistono due sistemi di misurazione della temperatura molto diffusi: Celsius e Fahrenheit. Il primo è molto diffuso in Europa, +mentre il secondo è molto utilizzato, ad esempio, negli Stati Uniti. -By Celsius scale water freezes at 0 degrees and boils at 100 degrees. By Fahrenheit water freezes -at 32 degrees and boils at 212 degrees. You may learn more from [wikipedia on Fahrenheit][wiki]. Use these two points -for conversion of other temperatures. +Secondo la scala Celsius, l'acqua congela a 0 gradi e bolle a 100 gradi. Secondo la scala Fahrenheit, l'acqua congela +a 32 gradi e bolle a 212 gradi. Puoi trovare maggiori informazioni su [wikipedia on Fahrenheit][wiki]. Usa questi due punti +per la conversione di altre temperature. [wiki]: http://en.wikipedia.org/wiki/Fahrenheit -You are to write program to convert degrees of Fahrenheit to Celsius. +Devi scrivere un programma per convertire i gradi Fahrenheit in Celsius. -**Input data** contains `N+1` values, first of them is `N` itself (**Note** that you should not try to convert it). -**Answer** should contain exactly `N` results, rounded to nearest integer and separated by spaces. +I **dati di input** contengono `N+1` valori, il primo dei quali è `N` stesso (**Nota**: non dovresti provare a convertirlo). +La ​​**risposta** dovrebbe contenere esattamente `N` risultati, arrotondati all'intero più vicino e separati da spazi. -Example: +Esempio: - data: + dati input: 5 495 353 168 -39 22 - answer: + risposta: 257 178 76 -39 -6 -*Please note that first `5` is not a temperature, but the amount of values to convert!* \ No newline at end of file + +*Si prega di notare che il primo `5` non è una temperatura, ma la quantità di valori da convertire!* From e6749e7d97378a11d4809c6a3a12c3405c2db45b Mon Sep 17 00:00:00 2001 From: Francesco-69 Date: Wed, 19 Nov 2025 18:57:32 +0100 Subject: [PATCH 22/35] Add files via upload --- it/task-8.md | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 it/task-8.md diff --git a/it/task-8.md b/it/task-8.md new file mode 100644 index 0000000..7965a67 --- /dev/null +++ b/it/task-8.md @@ -0,0 +1,39 @@ +When we speak about **arithmetic progression** (or arithmetic sequence) we mean a series +of numbers with a special property - each value is followed by the other, greater by predefined +amount (step). + +I.e. difference of `(K+1)`-th and `K`-th values is a constant. Here are examples of sequences + + 1 2 3 4 5 6 7 ... + 4 6 8 10 12 14 16... + 10 13 16 19 22 25 28... + +Since so, arithmetic sequence is completely defined by the first member (`A`) and the increment +value - step size - (`B`). First few members could be expressed as + + A + (A + B) + (A + 2B) + (A + 3B) + ... + +You are to calculate the sum of first members of arithmetic sequence. +[Wikipedia page][wiki] on arithmetic progression could be of significant help to one +who meets them for the first time. + +[wiki]: http://en.wikipedia.org/wiki/Arithmetic_progression + +**Input data:** first line contains the number of test-cases. +Other lines contain test-cases in form of triplets of values `A B N` where `A` is the first value of the sequence, +`B` is the step size and `N` is the number of first values which should be accounted. +**Answer:** you are to output results (sums of `N` first members) for each sequence, separated by spaces. + +Example: + + data: + 2 + 5 2 3 + 3 0 10 + + answer: + 21 30 + +_Explanation of the Example. In the first case we have sequence starting with `5` and increasing by `2` each time. +We want to sum `3` elements from it `5 + 7 + 9 = 21`. The second is easier. It starts with `3` but increment is `0`, +so it is `3 + 3 + ... + 3 = 30` (total of `10` elements)._ From 5e00e6fd6248014b4e1c7ce5b0072879d0ce155f Mon Sep 17 00:00:00 2001 From: Francesco-69 Date: Wed, 19 Nov 2025 19:02:23 +0100 Subject: [PATCH 23/35] Translate task-8.md to Italian Translated the explanation of arithmetic progression and input/output details from English to Italian. --- it/task-8.md | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/it/task-8.md b/it/task-8.md index 7965a67..98bfcee 100644 --- a/it/task-8.md +++ b/it/task-8.md @@ -1,39 +1,41 @@ -When we speak about **arithmetic progression** (or arithmetic sequence) we mean a series -of numbers with a special property - each value is followed by the other, greater by predefined -amount (step). +Quando parliamo di **progressione aritmetica** (o sequenza aritmetica) intendiamo una serie +di numeri con una proprietà speciale: ogni valore è seguito dall'altro, maggiore di un valore predefinito +(passo). -I.e. difference of `(K+1)`-th and `K`-th values is a constant. Here are examples of sequences +Cioè la differenza tra il valore `(K+1)`-esimo e il valore `K`-esimo è una costante. Ecco alcuni esempi di sequenze 1 2 3 4 5 6 7 ... 4 6 8 10 12 14 16... 10 13 16 19 22 25 28... -Since so, arithmetic sequence is completely defined by the first member (`A`) and the increment -value - step size - (`B`). First few members could be expressed as +Pertanto, la sequenza aritmetica è completamente definita dal primo elemento (`A`) e dal valore di incremento +- passo - (`B`). I primi elementi potrebbero essere espressi come A + (A + B) + (A + 2B) + (A + 3B) + ... -You are to calculate the sum of first members of arithmetic sequence. -[Wikipedia page][wiki] on arithmetic progression could be of significant help to one -who meets them for the first time. +Devi calcolare la somma dei primi elementi di una sequenza aritmetica. +[Pagina di Wikipedia][wiki] sulla progressione aritmetica potrebbe essere di grande aiuto per chi +la incontra per la prima volta. [wiki]: http://en.wikipedia.org/wiki/Arithmetic_progression -**Input data:** first line contains the number of test-cases. -Other lines contain test-cases in form of triplets of values `A B N` where `A` is the first value of the sequence, -`B` is the step size and `N` is the number of first values which should be accounted. -**Answer:** you are to output results (sums of `N` first members) for each sequence, separated by spaces. +**Dati di input:** la prima riga contiene il numero di casi di test. +Le altre righe contengono casi di test sotto forma di triplette di valori `A B N` dove `A` è il primo valore della sequenza, +`B` è la dimensione del passo e `N` è il numero di primi valori da considerare. +**Risposta:** si devono ottenere i risultati (somme dei primi `N` elementi) per ogni sequenza, separati da spazi. -Example: - data: +Esempio: + + dati: 2 5 2 3 3 0 10 - answer: + risposta: 21 30 -_Explanation of the Example. In the first case we have sequence starting with `5` and increasing by `2` each time. -We want to sum `3` elements from it `5 + 7 + 9 = 21`. The second is easier. It starts with `3` but increment is `0`, -so it is `3 + 3 + ... + 3 = 30` (total of `10` elements)._ +_Spiegazione dell'esempio. Nel primo caso abbiamo una sequenza che inizia con `5` e aumenta di `2` ogni volta. +Vogliamo sommare `3` elementi da essa `5 + 7 + 9 = 21`. Il secondo è più semplice. Inizia con `3` ma l'incremento è `0`, +quindi è `3 + 3 + ... + 3 = 30` (totale di `10` elementi)._ + From a516190392d80fc2bb62feed2595bdd9e92aec0c Mon Sep 17 00:00:00 2001 From: Francesco-69 Date: Wed, 19 Nov 2025 19:04:00 +0100 Subject: [PATCH 24/35] Add files via upload --- it/task-9.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 it/task-9.md diff --git a/it/task-9.md b/it/task-9.md new file mode 100644 index 0000000..c22f09a --- /dev/null +++ b/it/task-9.md @@ -0,0 +1,26 @@ + +Triangle is an object built of three line segments (sides of triangle), connected by ends. +[Wiki on triangles][wiki] provides more detailed explanation. +If we have three line segments with lengths `A B C` - we either can built a triangle with them +(for example with `3 4 5` or `3 4 7` - though this is with zero area) or we found it impossible +(for example `1 2 4`). + +[wiki]: http://en.wikipedia.org/wiki/Triangle + +You are given several triplets of values representing lengths of the sides of triangles. +You should tell from which triplets it is possible to build triangle and for which it is not. + +**Input data:** First line will contain number of triplets. +Other lines will contain triplets themselves (each in separate line). +**Answer:** You should output `1` or `0` for each triplet (`1` if triangle could be +built and `0` otherwise). + +Example: + + data: + 2 + 3 4 5 + 1 2 4 + + answer: + 1 0 \ No newline at end of file From 07b49e3d665f96b42a45ac8efa70133eb6d475e4 Mon Sep 17 00:00:00 2001 From: Francesco-69 Date: Wed, 19 Nov 2025 19:06:20 +0100 Subject: [PATCH 25/35] Translate triangle task description to Italian --- it/task-9.md | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/it/task-9.md b/it/task-9.md index c22f09a..d63d2b8 100644 --- a/it/task-9.md +++ b/it/task-9.md @@ -1,26 +1,26 @@ - -Triangle is an object built of three line segments (sides of triangle), connected by ends. -[Wiki on triangles][wiki] provides more detailed explanation. -If we have three line segments with lengths `A B C` - we either can built a triangle with them -(for example with `3 4 5` or `3 4 7` - though this is with zero area) or we found it impossible -(for example `1 2 4`). + +Un triangolo è un oggetto costituito da tre segmenti (lati del triangolo), collegati da estremità. +[Wiki sui triangoli][wiki] fornisce una spiegazione più dettagliata. +Se abbiamo tre segmenti di lunghezza `A B C`, possiamo costruire un triangolo con essi +(ad esempio con `3 4 5` o `3 4 7`, sebbene questo abbia area zero) oppure lo troviamo impossibile +(ad esempio `1 2 4`). [wiki]: http://en.wikipedia.org/wiki/Triangle -You are given several triplets of values representing lengths of the sides of triangles. -You should tell from which triplets it is possible to build triangle and for which it is not. +Ti vengono fornite diverse terne di valori che rappresentano le lunghezze dei lati dei triangoli. +Dovresti dire da quali terne è possibile costruire un triangolo e da quali no. -**Input data:** First line will contain number of triplets. -Other lines will contain triplets themselves (each in separate line). -**Answer:** You should output `1` or `0` for each triplet (`1` if triangle could be -built and `0` otherwise). +**Dati di input:** La prima riga conterrà il numero di terzine. +Le altre righe conterranno le terzine stesse (ciascuna su una riga separata). +**Risposta:** Dovresti restituire `1` o `0` per ogni terzina (`1` se il triangolo può essere +costruito e `0` altrimenti). -Example: +Esempio: - data: + dati: 2 3 4 5 1 2 4 - answer: - 1 0 \ No newline at end of file + risposte: + 1 0 From c1dd5402eba5df16112db8702aa55cd5ee5d7faf Mon Sep 17 00:00:00 2001 From: Francesco-69 Date: Wed, 19 Nov 2025 19:08:07 +0100 Subject: [PATCH 26/35] Add files via upload --- it/task-10.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 it/task-10.md diff --git a/it/task-10.md b/it/task-10.md new file mode 100644 index 0000000..e518c1c --- /dev/null +++ b/it/task-10.md @@ -0,0 +1,29 @@ + +Very common problem in computational programming is to determine the underlying law to which some phenomenon obeys. +For learning purpose let us practice a simple variant - discovering linear dependence by two given observations (for +example, how the price for some product depends on its size, weight etc.) + +Linear function is defined by an equation: + + y(x) = ax + b + +Where `a` and `b` are some constants. +For example, with `a=3, b=2` function will yield values `y = 2, 5, 8, 11...` +for `x = 0, 1, 2, 3...` + +Your task is to determine `a` and `b` by two points, belonging to the function. +I.e. you are told two pairs of values `(x1, y1), (x2, y2)` which satisfy the function equation +- and you should restore the equation itself. + +**Input data** have the number of test-cases in the first line +and then test-cases themselves in separate lines. +Each case contains `4` integers (`x1 y1 x2 y2`). +**Answers** should be integer too and you are to write them in line, separating with spaces and enclosing each pair in parenthesis, for example: + + input data: + 2 + 0 0 1 1 + 1 0 0 1 + + answer: + (1 0) (-1 1) From e8f176762825a9864288fd1a674cf035b51a5972 Mon Sep 17 00:00:00 2001 From: Francesco-69 Date: Wed, 19 Nov 2025 19:11:49 +0100 Subject: [PATCH 27/35] Translate task-10 from English to Italian --- it/task-10.md | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/it/task-10.md b/it/task-10.md index e518c1c..d6c354f 100644 --- a/it/task-10.md +++ b/it/task-10.md @@ -1,29 +1,29 @@ - -Very common problem in computational programming is to determine the underlying law to which some phenomenon obeys. -For learning purpose let us practice a simple variant - discovering linear dependence by two given observations (for -example, how the price for some product depends on its size, weight etc.) + +Un problema molto comune nella programmazione computazionale è determinare la legge di base a cui obbedisce un fenomeno. +A scopo didattico, esercitiamoci con una semplice variante: scoprire la dipendenza lineare tramite due osservazioni date (ad esempio, come il +prezzo di un prodotto dipende dalle sue dimensioni, dal suo peso, ecc.) -Linear function is defined by an equation: +La funzione lineare è definita dall' equazione: y(x) = ax + b -Where `a` and `b` are some constants. -For example, with `a=3, b=2` function will yield values `y = 2, 5, 8, 11...` -for `x = 0, 1, 2, 3...` +Dove `a` e `b` sono delle costanti. +Ad esempio, con `a=3, b=2` la funzione produrrà i valori `y = 2, 5, 8, 11...` +per `x = 0, 1, 2, 3...` -Your task is to determine `a` and `b` by two points, belonging to the function. -I.e. you are told two pairs of values `(x1, y1), (x2, y2)` which satisfy the function equation -- and you should restore the equation itself. +Il tuo compito è determinare `a` e `b` tramite due punti appartenenti alla funzione. +Ovvero, ti vengono fornite due coppie di valori `(x1, y1), (x2, y2)` che soddisfano l'equazione della funzione +- e dovresti ripristinare l'equazione stessa. -**Input data** have the number of test-cases in the first line -and then test-cases themselves in separate lines. -Each case contains `4` integers (`x1 y1 x2 y2`). -**Answers** should be integer too and you are to write them in line, separating with spaces and enclosing each pair in parenthesis, for example: - - input data: +**I dati di input** contengono il numero di casi di test nella prima riga +e poi i casi di test stessi in righe separate. +Ogni caso contiene `4` numeri interi (`x1 y1 x2 y2`). +**Anche le risposte** devono essere numeri interi e vanno scritte in riga, separate da spazi e racchiudendo ogni coppia tra parentesi, ad esempio: + dati input: 2 0 0 1 1 1 0 0 1 - answer: + risposte: (1 0) (-1 1) + From e1277f20f1435657d2bfda7fbf4900eb9221e473 Mon Sep 17 00:00:00 2001 From: Francesco-69 Date: Wed, 19 Nov 2025 19:12:54 +0100 Subject: [PATCH 28/35] Add files via upload --- it/task-11.md | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 it/task-11.md diff --git a/it/task-11.md b/it/task-11.md new file mode 100644 index 0000000..75d2966 --- /dev/null +++ b/it/task-11.md @@ -0,0 +1,41 @@ + +This programming exercise is intended to introduce numeral system basics to you. We start learninig +this concept by playing with decimal system which we use everyday (though you should keep in mind that computer does +not use it internally - it only converts numbers to it when they should be shown to user). + +As any number greater than 9 is represented by several digits, we can calculate the sum of these digits. For example, +for numbers `1492` and `1776` we get: + + 1 + 4 + 9 + 2 = 16 + 1 + 7 + 7 + 6 = 21 + +In this task you will be given several numbers and asked to calculate their sums of digits. + +**Important:** while many programming languages have built-in functions to convert numbers to strings +(from which digits could be extracted), you should not use this (since your goal is to learn some programming tricks). + +**Instead** you need to implement algorithm with repetitive division by 10 (base of numeral system) and summing up the +remainders. Read the [Number to digits][numtodig] article for details on the algorithm. + +[numtodig]: ../wiki/number-to-digits + +###Problem statement + +**Input data** are in the following format: + +- first line contains `N` - the number of values to process; +- and then `N` lines will follow describing the values for which sum of digits should be calculated by `3` integers `A B C`; +- for each case you need to multiply `A` by `B` and add `C` (i.e. `A * B + C`) - then calculate sum of digits of the result. + +**Answer** should have `N` results, also separated by spaces. For example: + + input data: + 3 + 11 9 1 + 14 90 232 + 111 15 111 + + answer: + 1 16 21 + +Here the first case requires to calculate `11*9+1 = 100` and its sum of digits is `1+0+0 = 1`. \ No newline at end of file From b8db50b14f31092faa697bb4837fc9dc95b30092 Mon Sep 17 00:00:00 2001 From: Francesco-69 Date: Wed, 19 Nov 2025 19:18:33 +0100 Subject: [PATCH 29/35] Translate task description to Italian Translated the task description from English to Italian and updated the formatting. --- it/task-11.md | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/it/task-11.md b/it/task-11.md index 75d2966..fe6fdd3 100644 --- a/it/task-11.md +++ b/it/task-11.md @@ -1,41 +1,42 @@ - -This programming exercise is intended to introduce numeral system basics to you. We start learninig -this concept by playing with decimal system which we use everyday (though you should keep in mind that computer does -not use it internally - it only converts numbers to it when they should be shown to user). + +Questo esercizio di programmazione ha lo scopo di introdurre le basi del sistema numerico. Inizieremo ad apprendere +questo concetto giocando con il sistema decimale che usiamo quotidianamente (anche se è importante tenere presente che il computer +non lo utilizza internamente, ma converte i numeri in esso solo quando devono essere mostrati all'utente). -As any number greater than 9 is represented by several digits, we can calculate the sum of these digits. For example, -for numbers `1492` and `1776` we get: +Poiché qualsiasi numero maggiore di 9 è rappresentato da più cifre, possiamo calcolare la somma di queste cifre. Ad esempio, +per i numeri `1492` e `1776` otteniamo: 1 + 4 + 9 + 2 = 16 1 + 7 + 7 + 6 = 21 -In this task you will be given several numbers and asked to calculate their sums of digits. +In questo compito ti verranno forniti diversi numeri e ti verrà chiesto di calcolare la somma delle loro cifre. -**Important:** while many programming languages have built-in functions to convert numbers to strings -(from which digits could be extracted), you should not use this (since your goal is to learn some programming tricks). +**Importante:** sebbene molti linguaggi di programmazione abbiano funzioni integrate per convertire i numeri in stringhe +(da cui è possibile estrarre cifre), non dovresti usarle (dato che il tuo obiettivo è imparare alcuni trucchi di programmazione). -**Instead** you need to implement algorithm with repetitive division by 10 (base of numeral system) and summing up the -remainders. Read the [Number to digits][numtodig] article for details on the algorithm. +**Invece** è necessario implementare un algoritmo con divisione ripetitiva per 10 (base del sistema numerico) e somma dei +resti. Leggi l'articolo [Numero in cifre][numtodig] per i dettagli sull'algoritmo. [numtodig]: ../wiki/number-to-digits -###Problem statement +###Enunciato del problema -**Input data** are in the following format: +**Datidi input** saranno nel seguente formato: -- first line contains `N` - the number of values to process; -- and then `N` lines will follow describing the values for which sum of digits should be calculated by `3` integers `A B C`; -- for each case you need to multiply `A` by `B` and add `C` (i.e. `A * B + C`) - then calculate sum of digits of the result. +- la prima riga contiene `N`, il numero di valori da elaborare; +- seguiranno le righe `N` che descrivono i valori per i quali la somma delle cifre deve essere calcolata con `3` numeri interi `A B C`; +- per ogni caso è necessario moltiplicare `A` per `B` e aggiungere `C` (ovvero `A * B + C`), quindi calcolare la somma delle cifre del risultato. + +**Risposta** dovrebbe avere `N` risultati, separati da spazi. Ad esempio: -**Answer** should have `N` results, also separated by spaces. For example: - - input data: + dati di input: 3 11 9 1 14 90 232 111 15 111 - answer: + risposta: 1 16 21 -Here the first case requires to calculate `11*9+1 = 100` and its sum of digits is `1+0+0 = 1`. \ No newline at end of file + +Qui il primo caso richiede di calcolare `11*9+1 = 100` e la sua somma di cifre è `1+0+0 = 1`. From 62a16e30f4061d632f933a600d8fc4192d8a80eb Mon Sep 17 00:00:00 2001 From: Francesco-69 Date: Fri, 21 Nov 2025 20:46:31 +0100 Subject: [PATCH 30/35] Add files via upload --- it/task-12.md | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 it/task-12.md diff --git a/it/task-12.md b/it/task-12.md new file mode 100644 index 0000000..c9b6a9e --- /dev/null +++ b/it/task-12.md @@ -0,0 +1,47 @@ +Dealing with remainders may cause heavy headache to novice programmers. Let us write a simple program which +has this operation for its core to study integer division better. At the same time we'll have some practice in +handing dates - which sometimes gives headache even to experienced coders. + + +In arithmetic, the remainder (or modulus) is the amount "left over" after performing the division of two integers +which do not divide evenly (from [Wiki][wiki]). This task will provide further practice with modulo operation. + +[wiki]: http://en.wikipedia.org/wiki/Remainder + +Suppose, we are given two timestamps - for example, when the train or ferry boat starts its travel and when it finishes. This +may look like: + + start: May 3, 17:08:30 + end : May 8, 12:54:15 + +and we are curious to know, how much time (in days, hours, minutes and seconds) is spent in traveling (perhaps, to +choose faster variant). How this could be achieved? + +One of the easiest way is: + +- convert both timestamps to big numbers, representing seconds from the beginning of the month (or year, or century); +- calculate their difference - i.e. travel time in seconds; +- convert this difference back to days, hours, minutes and seconds. + +First operation could be performed by multiplying minutes by `60` and hours by `60*60` etc. and summing all values up. +The third operation should be performed on contrary by several divisions with keeping remainders. + +In this task we are given several pair of timestamps. We suppose that both dates in the pair are always in the +same month, so only number of day will be given. We want to calculate difference between timestamps in each pair. + +**Input data:** the first line contains number of test-cases, other lines contain test-cases themselves. +Each test-case contains `8` numbers, `4` for each timestamp: `day1 hour1 min1 sec1 day2 hour2 min2 sec2` (second +timestamp will always be later than first). +**Answer:** for each test-case you are to output difference as following `(days hours minutes seconds)` - please +note brackets - separated by spaces. + +Example: + + input data: + 3 + 1 0 0 0 2 3 4 5 + 5 3 23 22 24 4 20 45 + 8 4 6 47 9 11 51 13 + + answer: + (1 3 4 5) (19 0 57 23) (1 7 44 26) From e096cae82b28cd7cd929c9fa4163bc23b8c40403 Mon Sep 17 00:00:00 2001 From: Francesco-69 Date: Fri, 21 Nov 2025 20:47:20 +0100 Subject: [PATCH 31/35] Add files via upload From b7a9e65acde386e3a6a763e353b908899bf03f07 Mon Sep 17 00:00:00 2001 From: Francesco-69 Date: Fri, 21 Nov 2025 20:53:56 +0100 Subject: [PATCH 32/35] Translate task description to Italian --- it/task-12.md | 51 ++++++++++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/it/task-12.md b/it/task-12.md index c9b6a9e..c226bef 100644 --- a/it/task-12.md +++ b/it/task-12.md @@ -1,47 +1,48 @@ -Dealing with remainders may cause heavy headache to novice programmers. Let us write a simple program which -has this operation for its core to study integer division better. At the same time we'll have some practice in -handing dates - which sometimes gives headache even to experienced coders. +Gestire i resti può causare grossi grattacapi ai programmatori alle prime armi. Scriviamo un semplice programma che +ha questa operazione al suo centro per studiare meglio la divisione intera. Allo stesso tempo, faremo un po' di pratica nella +gestione delle date, che a volte crea grattacapi anche ai programmatori più esperti. -In arithmetic, the remainder (or modulus) is the amount "left over" after performing the division of two integers -which do not divide evenly (from [Wiki][wiki]). This task will provide further practice with modulo operation. +In aritmetica, il resto (o modulo) è la quantità "rimasta" dopo aver eseguito la divisione di due numeri interi +che non sono divisibili in parti uguali (da [Wiki][wiki]). Questo esercizio fornirà ulteriore pratica con l'operazione modulo. [wiki]: http://en.wikipedia.org/wiki/Remainder -Suppose, we are given two timestamps - for example, when the train or ferry boat starts its travel and when it finishes. This -may look like: +Supponiamo di ricevere due timestamp, ad esempio quando il treno o il traghetto inizia il suo viaggio e quando lo termina. +Potrebbe apparire così: start: May 3, 17:08:30 end : May 8, 12:54:15 -and we are curious to know, how much time (in days, hours, minutes and seconds) is spent in traveling (perhaps, to -choose faster variant). How this could be achieved? +E siamo curiosi di sapere quanto tempo (in giorni, ore, minuti e secondi) viene impiegato per viaggiare (forse, per +scegliere una variante più veloce). Come si potrebbe ottenere questo risultato? -One of the easiest way is: +Uno dei modi più semplici è: -- convert both timestamps to big numbers, representing seconds from the beginning of the month (or year, or century); -- calculate their difference - i.e. travel time in seconds; -- convert this difference back to days, hours, minutes and seconds. +- convertire entrambi i timestamp in numeri grandi, che rappresentano i secondi dall'inizio del mese (o dell'anno o del secolo); +- calcolare la loro differenza, ovvero il tempo di percorrenza in secondi; +- riconvertire questa differenza in giorni, ore, minuti e secondi. -First operation could be performed by multiplying minutes by `60` and hours by `60*60` etc. and summing all values up. -The third operation should be performed on contrary by several divisions with keeping remainders. +La prima operazione potrebbe essere eseguita moltiplicando i minuti per `60` e le ore per `60*60` ecc. e sommando tutti i valori. +La terza operazione dovrebbe essere eseguita al contrario, eseguendo diverse divisioni mantenendo i resti. -In this task we are given several pair of timestamps. We suppose that both dates in the pair are always in the -same month, so only number of day will be given. We want to calculate difference between timestamps in each pair. +In questo compito ci vengono fornite diverse coppie di timestamp. Supponiamo che entrambe le date della coppia siano sempre nello +stesso mese, quindi verrà fornito solo il numero del giorno. Vogliamo calcolare la differenza tra i timestamp in ciascuna coppia. -**Input data:** the first line contains number of test-cases, other lines contain test-cases themselves. -Each test-case contains `8` numbers, `4` for each timestamp: `day1 hour1 min1 sec1 day2 hour2 min2 sec2` (second -timestamp will always be later than first). -**Answer:** for each test-case you are to output difference as following `(days hours minutes seconds)` - please -note brackets - separated by spaces. +**Dati di input:** la prima riga contiene il numero di casi di test, le altre righe contengono i casi di test stessi. +Ogni caso di test contiene `8` numeri, `4` per ogni timestamp: `giorno1 ora1 min1 sec1 giorno2 ora2 min2 sec2` (il secondo +timestamp sarà sempre successivo al primo). +**Risposta:** per ogni caso di test, la differenza deve essere visualizzata come segue `(giorni ore minuti secondi)` - si prega di +notare le parentesi quadre - separate da spazi. -Example: +Esempio: - input data: + dati input: 3 1 0 0 0 2 3 4 5 5 3 23 22 24 4 20 45 8 4 6 47 9 11 51 13 - answer: + risposte: (1 3 4 5) (19 0 57 23) (1 7 44 26) + From 14bfe78c33559abd323c7c4855cc4897c1aa06b5 Mon Sep 17 00:00:00 2001 From: Francesco-69 Date: Mon, 24 Nov 2025 12:03:25 +0100 Subject: [PATCH 33/35] Add files via upload --- it/task-54.md | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 it/task-54.md diff --git a/it/task-54.md b/it/task-54.md new file mode 100644 index 0000000..b0666d3 --- /dev/null +++ b/it/task-54.md @@ -0,0 +1,38 @@ + +*This task is inspired by the discussion in the [Blog on algorithms by Faisal Rahman](http://algoexplode.wordpress.com/) on similar task from +[ProjectEuler](http://projecteuler.net/problem=9)* + +As we know, the [Pythagorean Theorem](./pythagorean-theorem) tells us about the simple equation: + + a^2 + b^2 = c^2 + +There really exist such triples `a, b, c` of **integer** numbers, which satisfy this equation. This is not self-evident +fact, moreover there are no such triples for any other powers except `2` - this is the famous +[Fermat Theorem](http://en.wikipedia.org/wiki/Fermat's_Last_Theorem) which could not be solved for more than `350` +years. + +However, for the power of `2` there are countless amount of such triples. One of them `3, 4, 5`, for example. + +Nevertheless, it is not always easy to find a triple satisfying some specific conditions: + +**In this problem you need to write a program which for given value of `s = a + b + c` +will find the only triple which satisfies the equation.** + +For example, given sum of `12` the only `3, 4, 5` triple fits, for sum `30` the only `5, 12, 13` etc. + +**Input data** will contain the number of test-cases in the first line. +Other lines will contain a single value each - the sum for which triple should be found. +**Answer** should contain the values of `c^2` for each triple found (it is equal to `a^2 + b^2` of course), +separated with spaces. + +**Note:** the real values of `s` would be large enough, about `10e+7` - so the simplest solutions could be inefficient. + +Example: + + input data: + 2 + 12 + 30 + + answer: + 25 169 From 20f88f8c72e442c81cdfb537c1a7807b5c776f4f Mon Sep 17 00:00:00 2001 From: Francesco-69 Date: Mon, 24 Nov 2025 12:13:17 +0100 Subject: [PATCH 34/35] Translate task-54.md to Italian Translated the task description from English to Italian and updated example inputs and outputs. --- it/task-54.md | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/it/task-54.md b/it/task-54.md index b0666d3..f01e959 100644 --- a/it/task-54.md +++ b/it/task-54.md @@ -1,38 +1,39 @@ - -*This task is inspired by the discussion in the [Blog on algorithms by Faisal Rahman](http://algoexplode.wordpress.com/) on similar task from + +*Questo compito è ispirato alla discussione nel [Blog sugli algoritmi di Faisal Rahman](http://algoexplode.wordpress.com/) su un compito simile da [ProjectEuler](http://projecteuler.net/problem=9)* -As we know, the [Pythagorean Theorem](./pythagorean-theorem) tells us about the simple equation: +Come sappiamo, il [Teorema di Pitagora](./pythagorean-theorem) ci parla della semplice equazione: a^2 + b^2 = c^2 -There really exist such triples `a, b, c` of **integer** numbers, which satisfy this equation. This is not self-evident -fact, moreover there are no such triples for any other powers except `2` - this is the famous -[Fermat Theorem](http://en.wikipedia.org/wiki/Fermat's_Last_Theorem) which could not be solved for more than `350` -years. +Esistono realmente terne `a, b, c` di numeri **interi** che soddisfano questa equazione. Questo non è un fatto ovvio, +inoltre non esistono terne di questo tipo per altre potenze eccetto `2` - questo è il famoso +[Teorema di Fermat](http://en.wikipedia.org/wiki/Fermat's_Last_Theorem) che non poté essere risolto per più di `350` +anni. -However, for the power of `2` there are countless amount of such triples. One of them `3, 4, 5`, for example. +Tuttavia, per la potenza di `2` esistono innumerevoli terne di questo tipo. Una di queste, per esempio, `3, 4, 5`. -Nevertheless, it is not always easy to find a triple satisfying some specific conditions: +Tuttavia, non è sempre facile trovare una terna che soddisfi alcune condizioni specifiche: -**In this problem you need to write a program which for given value of `s = a + b + c` -will find the only triple which satisfies the equation.** +**In questo problema devi scrivere un programma che, dato il valore di `s = a + b + c` +trovi l'unica terna che soddisfa l'equazione.** -For example, given sum of `12` the only `3, 4, 5` triple fits, for sum `30` the only `5, 12, 13` etc. +Ad esempio, data la somma di `12`, si adattano solo `3, 4, 5`, per la somma di `30` si adattano solo `5, 12, 13` ecc. -**Input data** will contain the number of test-cases in the first line. -Other lines will contain a single value each - the sum for which triple should be found. -**Answer** should contain the values of `c^2` for each triple found (it is equal to `a^2 + b^2` of course), -separated with spaces. +**I dati di input** conterranno il numero di casi di test nella prima riga. +Le altre righe conterranno un singolo valore ciascuna, la somma per la quale si desidera trovare la tripla. +**La risposta** dovrebbe contenere i valori di `c^2` per ogni tripla trovata (ovviamente è uguale a `a^2 + b^2`), +separati da spazi. -**Note:** the real values of `s` would be large enough, about `10e+7` - so the simplest solutions could be inefficient. +**Nota:** i valori reali di `s` sarebbero sufficientemente grandi, circa `10e+7`, quindi le soluzioni più semplici potrebbero essere inefficienti. -Example: +Esempio: - input data: + dati input: 2 12 30 - answer: + risposta: 25 169 + From 96d70dd4a9088a8803fe26b012b6faf8317877ba Mon Sep 17 00:00:00 2001 From: Francesco-69 Date: Mon, 24 Nov 2025 12:15:55 +0100 Subject: [PATCH 35/35] Update task-54.md