-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
aggiunta prima fase fibonacci 2024-25
- Loading branch information
Showing
77 changed files
with
1,574 additions
and
1 deletion.
There are no files selected for viewing
Submodule asy_library
updated
13 files
+13 −0 | pictures/apple.asy | |
+11 −0 | pictures/banana.asy | |
+11 −0 | pictures/banana_peeled.asy | |
+13 −0 | pictures/barn.asy | |
+9 −0 | pictures/flag.asy | |
+2 −1 | pictures/flat_rock.asy | |
+32 −0 | pictures/kiosk.asy | |
+17 −0 | pictures/rock.asy | |
+69 −0 | pictures/scale.asy | |
+13 −0 | pictures/strawberry.asy | |
+31 −0 | pictures/table.asy | |
+13 −0 | pictures/watermelon.asy | |
+9 −2 | tools/svg_to_asy.py |
3 changes: 3 additions & 0 deletions
3
src/fibonacci-primarie/2024-prima-fase/contest/A11-connetti-stati/4-1-secondarie.asy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
access "../../../../asy_library/structures/histogram.asy" as histogram; | ||
unitsize(1cm); | ||
add(histogram.drawing(scale(1.5)*"secondarie", new Label[]{"corretta", "vuota", "scorretta"}, new real[]{2371, 474, 3000})); |
3 changes: 3 additions & 0 deletions
3
src/fibonacci-primarie/2024-prima-fase/contest/A11-connetti-stati/4-2-secondarie.asy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
access "../../../../asy_library/structures/histogram.asy" as histogram; | ||
unitsize(1cm); | ||
add(histogram.drawing(scale(1.5)*"secondarie", new Label[]{"corretta", "vuota", "scorretta"}, new real[]{840, 1077, 3928})); |
24 changes: 24 additions & 0 deletions
24
src/fibonacci-primarie/2024-prima-fase/contest/A11-connetti-stati/ex1.asy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import stati; | ||
|
||
unitsize(1cm); | ||
|
||
srand(43); | ||
path[] borders = make_borders(5); | ||
pair[][] farms; | ||
for (int i=0; i<3; ++i) { | ||
farms[i] = make_farms(2); | ||
add(shift(STEP*i,0)*country(borders, farms[i], (i+2), 2)); | ||
} | ||
|
||
pen mydot = linetype(new real[] {0,2}); | ||
|
||
draw(farms[0][0] -- shift(STEP,0)*farms[1][0], heavyred+mydot+6); | ||
draw(farms[0][1] -- shift(STEP*2,0)*farms[2][1], heavyred+mydot+6); | ||
draw(shift(STEP,0)*farms[1][1] -- shift(STEP*2,0)*farms[2][1], heavyred+mydot+6); | ||
draw(farms[0][0] -- shift(STEP,0)*farms[1][1], heavyred+mydot+6); | ||
draw(shift(STEP,0)*farms[1][0] -- shift(STEP,0)*farms[1][1], blue+4); | ||
draw(shift(STEP*2,0)*farms[2][0] -- shift(STEP*2,0)*farms[2][1], blue+4); | ||
|
||
for (int i=0; i<3; ++i) { | ||
add(shift(STEP*i,0)*country_farms(borders, farms[i], (i+2), 2)); | ||
} |
114 changes: 114 additions & 0 deletions
114
src/fibonacci-primarie/2024-prima-fase/contest/A11-connetti-stati/ex1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 27 additions & 0 deletions
27
src/fibonacci-primarie/2024-prima-fase/contest/A11-connetti-stati/ex2.asy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import stati; | ||
|
||
unitsize(1cm); | ||
|
||
srand(43); | ||
path[] borders = make_borders(5); | ||
pair[][] farms; | ||
for (int i=0; i<2; ++i) { | ||
farms[i] = make_farms(2); | ||
add(shift(STEP*i,0)*country(borders, farms[i], (i+3), 2)); | ||
} | ||
|
||
void arrdraw(pair a, pair b, pen p) { | ||
draw(a -- (b + unit(a-b)*1.2), p, EndArrow(15)); | ||
} | ||
|
||
pen mydot = linetype(new real[] {0,2}); | ||
|
||
arrdraw(farms[0][0], shift(STEP,0)*farms[1][0], heavyred+mydot+6); | ||
arrdraw(farms[0][1], shift(STEP,0)*farms[1][1], heavyred+mydot+6); | ||
arrdraw(shift(STEP,0)*farms[1][1], farms[0][0], heavyred+mydot+6); | ||
arrdraw(shift(STEP,0)*farms[1][0], shift(STEP,0)*farms[1][1], blue+4); | ||
arrdraw(farms[0][0], farms[0][1], blue+4); | ||
|
||
for (int i=0; i<2; ++i) { | ||
add(shift(STEP*i,0)*country_farms(borders, farms[i], (i+3), 2)); | ||
} |
111 changes: 111 additions & 0 deletions
111
src/fibonacci-primarie/2024-prima-fase/contest/A11-connetti-stati/ex2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions
11
src/fibonacci-primarie/2024-prima-fase/contest/A11-connetti-stati/immagine.asy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import stati; | ||
|
||
unitsize(1cm); | ||
|
||
path[] borders = make_borders(n); | ||
pair[][] farms; | ||
for (int i=0; i<n; ++i) { | ||
farms[i] = make_farms(s); | ||
add(shift(STEP*i,0)*country(borders, farms[i], i, s)); | ||
add(shift(STEP*i,0)*country_farms(borders, farms[i], i, s)); | ||
} |
51 changes: 51 additions & 0 deletions
51
src/fibonacci-primarie/2024-prima-fase/contest/A11-connetti-stati/question.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import variants from "./variants.py"; | ||
|
||
|
||
A _Carotandia_ ci sono $\js{n}$ paesi, e in ognuno di essi ci sono $\js{s}$ fattorie. | ||
Tip-Tap vuole costruire delle strade che colleghino tutte le fattorie. | ||
Una strada tra due fattorie dello stesso paese costa $1$ carota, mentre una strada tra fattorie di paesi diversi costa $2$ carote. | ||
Per esempio, se ci fossero tre paesi con due fattorie ciascuno, si potrebbero collegare le fattorie come in figura. Questo piano costa due carote per ognuna delle quattro strade tratteggiate, più una carota per ciascuna delle altre due strade, per un totale di dieci carote: | ||
|
||
 | ||
|
||
In questo esempio, ci sono anche altri piani validi, ciascuno con un costo di sette carote o più. | ||
Invece, a _Carotandia_ ci sono $\js{n}$ paesi con $\js{s}$ fattorie: | ||
|
||
 | ||
|
||
Qual è il minimo numero di carote che Tip-Tap deve spendere affinché da ogni fattoria si possa raggiungere ogni altra fattoria, eventualmente percorrendo più strade? | ||
|
||
- [x] $\js{ans1}$ | ||
- [ ] $\js{wrong1[0]}$ | ||
- [ ] $\js{wrong1[1]}$ | ||
- [ ] $\js{wrong1[2]}$ | ||
- [ ] $\js{wrong1[3]}$ | ||
|
||
> Dato che le strade all'interno dello stesso paese costano poco, conviene intanto collegare le fattorie all'interno dello stesso paese. Per ogni paese servono $\js{s-1}$ fattorie. Ad esempio, colleghiamo la fattoria $1$ con la fattoria $2$, la fattoria $2$ con la fattoria $3$, ..., la fattoria $\js{s-1}$ con la fattoria $\js{s}$). Quindi il costo parziale è di $\js{n*(s-1)}$ carote. | ||
> Adesso dobbiamo anche connettere i paesi tra di loro, e servono altre $\js{n-1}$ strade di costo $2$ carote. Ad esempio, colleghiamo l'ultima fattoria di ogni paese (tranne l'ultimo) con la prima di quello successivo. Il costo totale è $\js{2*(n-1) + n*(s-1)}$ carote. | ||
> | ||
>  | ||
--- | ||
|
||
Mettiamo ora che le strade che Tip-Tap costruisce siano a **senso unico**, come in questo esempio: | ||
|
||
 | ||
|
||
Questo piano costa otto carote ($3 \times 2 + 2 \times 1$), e consente di poter andare da ogni fattoria ad ogni altra rispettando i sensi unici. | ||
Come prima, ci sono anche altri piani validi, ciascuno con un costo di sei carote o più. | ||
Ricordando che a _Carotandia_ ci sono $\js{n}$ paesi con $\js{s}$ fattorie: | ||
|
||
 | ||
|
||
Qual è il minimo numero di carote che Tip-Tap deve spendere affinché da ogni fattoria si possa raggiungere ogni altra fattoria, eventualmente percorrendo più strade, ma rispettando sempre i sensi unici? | ||
|
||
- [x] $\js{ans2}$ | ||
- [ ] $\js{wrong2[0]}$ | ||
- [ ] $\js{wrong2[1]}$ | ||
- [ ] $\js{wrong2[2]}$ | ||
- [ ] $\js{wrong2[3]}$ | ||
|
||
> Nel problema precedente, abbiamo formato una linea composta da tutte le $\js{n*s}$ città. Assegniamo lo stesso verso a tutte le strade della linea, in modo che dalla prima città si possa raggiungere l'ultima. Ma in questo modo dall'ultima città non se ne può raggiungere nessun'altra. Per rimediare, creiamo una nuova strada che collega l'ultima città alla prima, pagando un costo aggiuntivo di $2$ carote. | ||
> | ||
>  |
88 changes: 88 additions & 0 deletions
88
src/fibonacci-primarie/2024-prima-fase/contest/A11-connetti-stati/stati.asy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
access "../../../../asy_library/pictures/barn.asy" as barn; | ||
|
||
real STEP = 9; | ||
|
||
pen[] barncols = {red, deepgreen, olive, blue, heavycyan}; | ||
pen[] fieldcols = {palegreen, paleyellow, palegray, palered, 0.5*palegreen+0.5*paleyellow}; | ||
|
||
path wiggline(pair a, pair b) { | ||
int n = 2 + rand()%8; | ||
real r = 2; | ||
pair s = (b-a)/n; | ||
path p = a; | ||
for (int i=1; i<n; ++i) p = p -- a + i*s + (unitrand()-0.5, unitrand()-0.5)*r; | ||
p = p -- b; | ||
return p; | ||
} | ||
|
||
path[] make_borders(int n) { | ||
path[] borders; | ||
for (int i=0; i<=n; ++i) | ||
borders[i] = wiggline((-2,-2), (-2,9)); | ||
return borders; | ||
} | ||
|
||
int[] gen_skips(int s) { | ||
int[] skips; | ||
if (s == 1) { | ||
skips[0] = rand() % 6; | ||
} else if (s == 2) { | ||
skips[0] = (rand()%3) * 2; | ||
skips[1] = (skips[0]+2+rand()%2)%6; | ||
skips[0] += rand()%2; | ||
skips = sort(skips); | ||
} else if (s == 3 && rand()%4 > 0) { | ||
skips[0] = skips[1] = skips[2] = 0; | ||
while (skips[0] == skips[1] && skips[1] == skips[2]) { | ||
skips[0] = rand()%2; | ||
skips[1] = rand()%2; | ||
skips[2] = rand()%2; | ||
} | ||
skips[1] += 2; | ||
skips[2] += 4; | ||
} | ||
if (s == 3 && skips.length == 0) { | ||
skips[0] = 2; | ||
skips[1] = 3; | ||
skips[2] = rand()%2 + (rand()%2 == 0 ? 0 : 4); | ||
skips = sort(skips); | ||
} | ||
return skips; | ||
} | ||
|
||
int[] invert(int[] v) { | ||
int[] w; | ||
int j=0; | ||
for (int i=0; i<6; ++i) { | ||
if (j < v.length && v[j] == i) j += 1; | ||
else w[w.length] = i; | ||
} | ||
return w; | ||
} | ||
|
||
pair[] make_farms(int s) { | ||
int[] v = gen_skips(s > 3 ? 6-s : s); | ||
if (s >= 3) v = invert(v); | ||
pair[] farms; | ||
for (int p : v) { | ||
int x = p%2; | ||
int y = p#2; | ||
farms[farms.length] = 3*(x, y)+(unitrand(), unitrand())*1.5; | ||
} | ||
return farms; | ||
} | ||
|
||
picture country(path[] borders, pair[] farms, int i, int n) { | ||
picture pic; | ||
path border = borders[i] -- wiggline((-2,9), (STEP-2,9)) -- shift(STEP,0)*reverse(borders[i+1]) -- wiggline((STEP-2,-2), (-2,-2)) -- cycle; | ||
filldraw(pic, border, fieldcols[i], black+5); | ||
return pic; | ||
} | ||
|
||
picture country_farms(path[] borders, pair[] farms, int i, int n) { | ||
picture pic; | ||
for (pair f : farms) { | ||
add(pic, shift(f)*barn.drawing(0.3, barncols[i])); | ||
} | ||
return pic; | ||
} |
39 changes: 39 additions & 0 deletions
39
src/fibonacci-primarie/2024-prima-fase/contest/A11-connetti-stati/variants.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import json | ||
|
||
variants_input = [ | ||
dict(n=4, s=4), | ||
dict(n=4, s=5), | ||
dict(n=5, s=3), | ||
dict(n=5, s=4), | ||
dict(n=3, s=5), | ||
] | ||
|
||
def check_no_ugual_answer(c, ws): | ||
s = {c} | ||
for w in ws: | ||
s.add(w) | ||
|
||
return len(s) == 5 | ||
|
||
|
||
def build_variant(n, s): | ||
ans1 = n*(s-1) + (n-1) * 2 | ||
ans2 = ans1 + 2 | ||
|
||
wrong1=[ans2]+[n*s, n*s + n + 2, n+s] | ||
wrong2=[ans1]+[n*s, n*s + n + 2, n*s + 4*(s-1)] | ||
|
||
assert check_no_ugual_answer(ans1, wrong1) | ||
assert check_no_ugual_answer(ans2, wrong2) | ||
|
||
return dict( | ||
n=n, | ||
s=s, | ||
ans1=ans1, | ||
wrong1=wrong1, | ||
ans2=ans2, | ||
wrong2=wrong2, | ||
) | ||
|
||
|
||
print(json.dumps([build_variant(**data) for i, data in enumerate(variants_input)])) |
3 changes: 3 additions & 0 deletions
3
src/fibonacci-primarie/2024-prima-fase/contest/A4-sottrai-potenze/3-1-secondarie.asy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
access "../../../../asy_library/structures/histogram.asy" as histogram; | ||
unitsize(1cm); | ||
add(histogram.drawing(scale(1.5)*"secondarie", new Label[]{"corretta", "vuota", "scorretta"}, new real[]{2058, 521, 3266})); |
3 changes: 3 additions & 0 deletions
3
src/fibonacci-primarie/2024-prima-fase/contest/A4-sottrai-potenze/3-2-secondarie.asy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
access "../../../../asy_library/structures/histogram.asy" as histogram; | ||
unitsize(1cm); | ||
add(histogram.drawing(scale(1.5)*"secondarie", new Label[]{"corretta", "vuota", "scorretta"}, new real[]{1102, 982, 3761})); |
3 changes: 3 additions & 0 deletions
3
src/fibonacci-primarie/2024-prima-fase/contest/A4-sottrai-potenze/4-1-primarie.asy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
access "../../../../asy_library/structures/histogram.asy" as histogram; | ||
unitsize(1cm); | ||
add(histogram.drawing(scale(1.5)*"primarie", new Label[]{"corretta", "vuota", "scorretta"}, new real[]{742, 283, 1621})); |
3 changes: 3 additions & 0 deletions
3
src/fibonacci-primarie/2024-prima-fase/contest/A4-sottrai-potenze/4-2-primarie.asy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
access "../../../../asy_library/structures/histogram.asy" as histogram; | ||
unitsize(1cm); | ||
add(histogram.drawing(scale(1.5)*"primarie", new Label[]{"corretta", "vuota", "scorretta"}, new real[]{446, 441, 1759})); |
6 changes: 6 additions & 0 deletions
6
src/fibonacci-primarie/2024-prima-fase/contest/A4-sottrai-potenze/lavagna1.asy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
access "../../../../asy_library/pictures/picture_frame.asy" as picture_frame; | ||
access "../../../../asy_library/pictures/bunny_polychrome.asy" as bunny_polychrome; | ||
import "lib.asy" as lib; | ||
|
||
size(300); | ||
add(lavagna(string(a1))); |
6 changes: 6 additions & 0 deletions
6
src/fibonacci-primarie/2024-prima-fase/contest/A4-sottrai-potenze/lavagna2.asy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
access "../../../../asy_library/pictures/picture_frame.asy" as picture_frame; | ||
access "../../../../asy_library/pictures/bunny_polychrome.asy" as bunny_polychrome; | ||
import "lib.asy" as lib; | ||
|
||
size(300); | ||
add(lavagna(string(a2))); |
11 changes: 11 additions & 0 deletions
11
src/fibonacci-primarie/2024-prima-fase/contest/A4-sottrai-potenze/lib.asy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
access "../../../../asy_library/pictures/picture_frame.asy" as picture_frame; | ||
access "../../../../asy_library/pictures/bunny_polychrome.asy" as bunny_polychrome; | ||
picture lavagna(string s) { | ||
picture pic; | ||
add(pic, picture_frame.drawing()); | ||
filldraw(pic, (-1.8,-1.5)--(1.8,-1.5)--(1.8,1.4)--(-1.8,1.4)--cycle, gray(0.15), white); | ||
label(pic, scale(6)*s, (0,0), white); | ||
add(pic, shift((-2.3, -1))*reflect((0,1),(0,-1))*bunny_polychrome.drawing(0.5, bunny_polychrome.tiptap_col)); | ||
add(pic, shift((2.3, -1))*bunny_polychrome.drawing(0.5, bunny_polychrome.allie_col)); | ||
return pic; | ||
} |
45 changes: 45 additions & 0 deletions
45
src/fibonacci-primarie/2024-prima-fase/contest/A4-sottrai-potenze/question.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import variants from "./variants.py"; | ||
|
||
Per esercitarsi nelle sottrazioni, Tip-Tap e Allie hanno inventato un gioco. Hanno scritto il numero $\js{a1}$ sulla lavagna e devono renderlo uguale a $0$ con una sequenza, la più breve possibile, di operazioni di questo tipo: | ||
- diminuire di ${1}$ una qualsiasi cifra del numero; | ||
- sottrarre $\js{b1}$ al numero (se il numero è almeno $\js{b1}$). | ||
|
||
Ad ogni operazione, dopo aver calcolato il risultato, lo sostituiscono al numero scritto sulla lavagna. | ||
Qual è il numero minimo di operazioni che devono fare per rendere il numero pari a $0$, partendo da $\js{a1}$? | ||
|
||
 | ||
|
||
- [x] $\js{ans1}$ | ||
- [ ] $\js{wrong1[0]}$ | ||
- [ ] $\js{wrong1[1]}$ | ||
- [ ] $\js{wrong1[2]}$ | ||
- [ ] $\js{wrong1[3]}$ | ||
|
||
> Per la proprietà commutativa, l'ordine delle sottrazioni non importa, quindi possiamo ipotizzare di fare prima le operazioni di sottrarre $\js{b1}$, e poi le operazioni per diminuire le cifre di $1$. | ||
> Proviamo a sottrarre $\js{b1}$ un po' di volte ($0, 1, 2, \ldots$), e il numero di mosse rimanenti è la somma delle cifre del numero sulla lavagna. | ||
> Sottraendo $\js{b1}$ il numero giusto di volte, la somma delle cifre diventa particolarmente piccola. | ||
> | ||
>  | ||
>  | ||
--- | ||
|
||
Tip-Tap e Allie ora hanno scritto un nuovo numero $\js{a2}$ sulla lavagna, e le operazioni consentite sono: | ||
- diminuire di ${1}$ una qualsiasi cifra del numero; | ||
- sottrarre $\js{b2}$ al numero (se il numero è almeno $\js{b2}$). | ||
|
||
Qual è il numero minimo di operazioni che devono fare per rendere il numero pari a $0$, partendo da $\js{a2}$? | ||
|
||
 | ||
|
||
- [x] $\js{ans2}$ | ||
- [ ] $\js{wrong2[0]}$ | ||
- [ ] $\js{wrong2[1]}$ | ||
- [ ] $\js{wrong2[2]}$ | ||
- [ ] $\js{wrong2[3]}$ | ||
|
||
> Qui $\js{a2}$ è grande, quindi provare a sottrarre $\js{b2}$ finché il numero sulla lavagna non è negativo è troppo lungo. | ||
> Ma possiamo notare che, se troviamo una sequenza con risposta $\js{ans2}$, non ha senso sottrarre $\js{b2}$ più di $\js{ans2}$ volte, e questo accorcia i conti. | ||
> | ||
>  | ||
>  |
Oops, something went wrong.