-
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 seconda fase fibonacci 2025
- Loading branch information
Showing
87 changed files
with
1,740 additions
and
1 deletion.
There are no files selected for viewing
Submodule asy_library
updated
7 files
+13 −0 | pictures/eggplant.asy | |
+60 −0 | pictures/lightbulb.asy | |
+31 −0 | pictures/pan.asy | |
+27 −0 | pictures/potato.asy | |
+33 −0 | pictures/stove.asy | |
+38 −0 | pictures/switch.asy | |
+13 −0 | pictures/tomato.asy |
18 changes: 18 additions & 0 deletions
18
src/fibonacci-primarie/2024-seconda-fase/contest/contest.mdx
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,18 @@ | ||
<Contest> | ||
|
||
## Sezione 1: procedimenti procedurali | ||
|
||
<Section> | ||
<Problem points={[5, 1, 0]}><P1SaltoOstacoli /></Problem> | ||
<Problem points={[5, 1, 0]}><P2Spiedino /></Problem> | ||
</Section> | ||
|
||
## Sezione 2: programmazione | ||
|
||
<Section> | ||
<Problem points={[5, 0, 0]}><S1Pranzo /></Problem> | ||
<Problem points={[5, 0, 0]}><S2Spesa /></Problem> | ||
<Problem points={[5, 0, 0]}><S3Corridoio /></Problem> | ||
</Section> | ||
|
||
</Contest> |
52 changes: 52 additions & 0 deletions
52
src/fibonacci-primarie/2024-seconda-fase/contest/p-1-salto-ostacoli/code-alt.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,52 @@ | ||
access "../../../../asy_library/structures/layout.asy" as layout; | ||
|
||
unravel layout; // per evitare di scrivere layout.cose tutto il tempo | ||
|
||
unitsize(1cm); | ||
|
||
TEXT_SIZE = 2; | ||
ALIGN = (0, 0.5); | ||
BLOCK_PADDING = .3; | ||
|
||
element P = | ||
row(2, 0, (0.5,0.5), | ||
block_sequence( | ||
start_block(e("Strategia 1")), | ||
for_block( | ||
block_content(e("ripeti mentre"), cond_block(data_block(e("posizione")), e("minore di"), data_block(e("traguardo"))), e(":")), | ||
else_block( | ||
block_content(e("se"), cond_block(e("pietra marrone"))), | ||
block_sequence( | ||
instr_block(element("salta")), | ||
instr_block(element("salta")) | ||
), | ||
block_content(e("altrimenti: ")), | ||
instr_block(element("avanza")) | ||
) | ||
) | ||
), | ||
block_sequence( | ||
start_block(e("Strategia 2")), | ||
for_block( | ||
block_content(e("ripeti mentre"), cond_block(data_block(e("posizione")), e("minore di"), data_block(e("traguardo"))), e(":")), | ||
instr_block(e("salta")) | ||
) | ||
), | ||
block_sequence( | ||
start_block(e("Strategia 3")), | ||
for_block( | ||
block_content(e("ripeti mentre"), cond_block(data_block(e("posizione")), e("minore di"), data_block(e("traguardo"))), e(":")), | ||
else_block( | ||
block_content(e("se"), cond_block(e("pietra marrone"))), | ||
instr_block(element("salta")), | ||
block_content(e("altrimenti: ")), | ||
block_sequence( | ||
instr_block(element("avanza")), | ||
instr_block(element("avanza")) | ||
) | ||
) | ||
) | ||
) | ||
); | ||
|
||
add(P.drawing()); |
24 changes: 24 additions & 0 deletions
24
src/fibonacci-primarie/2024-seconda-fase/contest/p-1-salto-ostacoli/code.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 @@ | ||
access "../../../../asy_library/structures/layout.asy" as layout; | ||
|
||
unravel layout; // per evitare di scrivere layout.cose tutto il tempo | ||
|
||
unitsize(1cm); | ||
|
||
TEXT_SIZE = 2; | ||
ALIGN = (0, 0.5); | ||
BLOCK_PADDING = .3; | ||
|
||
element P = | ||
block_sequence( | ||
for_block( | ||
block_content(e("ripeti mentre"), cond_block(data_block(e("posizione")), e("minore di"), data_block(e("traguardo"))), e(":")), | ||
else_block( | ||
block_content(e("se"), cond_block(e("pietra marrone"))), | ||
instr_block(element("salta")), | ||
block_content(e("altrimenti: ")), | ||
instr_block(element("avanza")) | ||
) | ||
) | ||
); | ||
|
||
add(P.drawing()); |
18 changes: 18 additions & 0 deletions
18
src/fibonacci-primarie/2024-seconda-fase/contest/p-1-salto-ostacoli/fig.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,18 @@ | ||
unitsize(1cm); | ||
|
||
access "../../../../asy_library/pictures/carrot.asy" as carrot; | ||
access "../../../../asy_library/pictures/flat_rock.asy" as flat_rock; | ||
access "../../../../asy_library/pictures/rock.asy" as rock; | ||
access "../../../../asy_library/pictures/bunny_polychrome.asy" as bunny_polychrome; | ||
access "../../../../asy_library/pictures/flag.asy" as flag; | ||
|
||
int[] rocks = {1, 0, 1, 2, 1, 1, 0, 1, 1, 2, 0, 0, 1, 1, 0, 2, 0, 0}; | ||
picture[] pics = {flat_rock.drawing(0.5, gray), flat_rock.drawing(0.5, brown), shift(0,1)*rock.drawing(0.3,gray)}; | ||
|
||
for (int i=0; i<rocks.length; ++i) { | ||
add(shift(4*i, -2.25)*pics[rocks[i]]); | ||
label(scale(6)*string(i+1), (4*i,-4.8)); | ||
} | ||
|
||
add(shift(-4, -0.25)*reflect((2, 1), (2, 0))*bunny_polychrome.drawing(0.85, bunny_polychrome.bunny_col)); | ||
add(shift(4*(rocks.length-3) - 1, -0.25)*reflect((2, 1), (2, 0))*flag.drawing(0.85)); |
3 changes: 3 additions & 0 deletions
3
src/fibonacci-primarie/2024-seconda-fase/contest/p-1-salto-ostacoli/primarie1.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[]{203, 12, 291})); |
3 changes: 3 additions & 0 deletions
3
src/fibonacci-primarie/2024-seconda-fase/contest/p-1-salto-ostacoli/primarie2.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[]{132, 9, 365})); |
66 changes: 66 additions & 0 deletions
66
src/fibonacci-primarie/2024-seconda-fase/contest/p-1-salto-ostacoli/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,66 @@ | ||
Bunny è ormai appassionato di percorsi ad ostacoli, e si trova quindi ora sulla casella $1$ di questo nuovo percorso: | ||
|
||
 | ||
|
||
Come sempre, il suo obbiettivo è **raggiungere o superare** la casella numero $17$ dove c'è la bandierina del traguardo. | ||
Bunny può fare le seguenti cose: | ||
+ **avanza**: Bunny avanza alla casella successiva; | ||
+ **salta**: Bunny supera la casella successiva con un salto, atterrando su quella dopo; | ||
+ **posizione**: la posizione corrente di Bunny; | ||
+ **traguardo**: la posizione del traguardo; | ||
+ **pietra marrone**: vero se Bunny si trova ora su una pietra marrone. | ||
|
||
Come nell'ultimo percorso ad ostacoli, sul percorso ci sono delle *grandi rocce*! Bunny non può arrivare su una casella occupata da una *grande roccia*, altrimenti cadrebbe, ma può superarla grazie ad un'azione **salta**. | ||
Se Bunny segue il procedimento qui sotto, riesce a raggiungere la bandierina? | ||
|
||
 | ||
|
||
- [ ] no, perchè si ferma prima di arrivare al traguardo senza cadere | ||
- [ ] si, raggiunge o supera la bandierina | ||
- [ ] no, perchè cade sulla *grande roccia* in posizione $4$ | ||
- [X] no, perchè cade sulla *grande roccia* in posizione $10$ | ||
- [ ] no, perchè cade sulla *grande roccia* in posizione $16$ | ||
|
||
> Bunny cade sulla *grande roccia* in posizione $10$. | ||
> | ||
> Inizialmente si trova su una roccia marrone, e quindi salta arrivando in posizione $3$. | ||
> Anche lì la roccia è marrone quindi salta di nuovo fino in posizione 5, e ancora una volta fino in posizione 7. | ||
> A questo punto la roccia è grigia, e quindi avanza alla posizione 8. | ||
> Ma dato che la roccia lì è marrone, salta cadendo direttamente sulla *grande roccia* in posizione $10$. | ||
> | ||
>  | ||
>  | ||
--- | ||
|
||
Sempre nello stesso percorso ad ostacoli, Bunny vuole provare un po' di strategie diverse: | ||
|
||
 | ||
|
||
 | ||
|
||
Quali di queste strategie gli consentono di raggiungere o superare il traguardo? | ||
|
||
|
||
- [ ] la strategia 1 | ||
- [ ] la strategia 2 | ||
- [ ] la strategia 3 | ||
- [x] le strategie 1 e 2 | ||
- [ ] le strategie 2 e 3 | ||
|
||
> Funzionano entrambe le strategie 1 e 2. | ||
> | ||
> Nella strategia 2 Bunny salta sempre, toccando tutte le posizioni dispari e quindi evitando tutte le grandi rocce, | ||
> che si trovano invece in posizioni pari, fino ad arrivare al traguardo in posizione $17$. | ||
> | ||
> Nella strategia 1, Bunny fa i salti a coppie: questo lo porta attraverso le posizioni $5$, $9$ e $13$, che hanno tutte | ||
> la roccia marrone, per poi arrivare sul traguardo in posizione $17$ senza aver mai fatto avanza. | ||
> | ||
> Nella strategia 3, invece, Bunny cade sulla roccia $16$. | ||
> Inizia saltando sulle rocce marroni in posizione $3$ e $5$ per arrivare alla posizione $7$. | ||
> Da lì avanza due volte alla posizione $9$. | ||
> A quel punto salta ancora alla posizione $11$, per poi avanzare due volte fino alla posizione $13$. | ||
> Quindi salta in posizione $15$, e da lì avanza andando a scontrarsi contro la grande roccia. | ||
> | ||
>  | ||
>  |
3 changes: 3 additions & 0 deletions
3
src/fibonacci-primarie/2024-seconda-fase/contest/p-1-salto-ostacoli/secondarie1.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[]{833, 14, 400})); |
3 changes: 3 additions & 0 deletions
3
src/fibonacci-primarie/2024-seconda-fase/contest/p-1-salto-ostacoli/secondarie2.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[]{629, 7, 611})); |
29 changes: 29 additions & 0 deletions
29
src/fibonacci-primarie/2024-seconda-fase/contest/p-2-spiedino/code.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,29 @@ | ||
access "../../../../asy_library/structures/layout.asy" as layout; | ||
|
||
unravel layout; // per evitare di scrivere layout.cose tutto il tempo | ||
|
||
unitsize(1cm); | ||
|
||
TEXT_SIZE = 2; | ||
ALIGN = (0, 0.5); | ||
|
||
element P = row( | ||
BLOCK_PADDING, | ||
fill_space=0, | ||
block_sequence( | ||
instr_block(element("imposta"), choice_block(e("valore")), element("a"), data_block(e("1"))), | ||
instr_block(element("imposta"), choice_block(e("i")), element("a"), data_block(e("1"))), | ||
for_block( | ||
block_content(e("ripeti"), data_block(e("24")), e("volte:")), | ||
block_sequence( | ||
if_block( | ||
block_content(e("se"), cond_block(data_block(e("cibo in posizione"), data_block(e("i"))), e("è diverso da"), data_block(e("cibo in posizione"), data_block(data_block(e("i")), e("+"), data_block(e("1")))))), | ||
instr_block(e("aumenta"), choice_block(e("valore")), element("di"), data_block(e("1"))) | ||
), | ||
instr_block(e("aumenta"), choice_block(e("i")), element("di"), data_block(e("1"))) | ||
) | ||
) | ||
) | ||
); | ||
|
||
add(P.drawing()); |
41 changes: 41 additions & 0 deletions
41
src/fibonacci-primarie/2024-seconda-fase/contest/p-2-spiedino/fig.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,41 @@ | ||
access "../../../../asy_library/pictures/bunny_polychrome.asy" as bunny_polychrome; | ||
access "../../../../asy_library/pictures/apple.asy" as apple; | ||
access "../../../../asy_library/pictures/banana.asy" as banana; | ||
access "../../../../asy_library/pictures/strawberry.asy" as strawberry; | ||
access "../../../../asy_library/pictures/watermelon.asy" as watermelon; | ||
access "../../../../asy_library/pictures/tomato.asy" as tomato; | ||
access "../../../../asy_library/pictures/carrot.asy" as carrot; | ||
access "../../../../asy_library/pictures/potato.asy" as potato; | ||
access "../../../../asy_library/pictures/eggplant.asy" as eggplant; | ||
|
||
path rect(pair a, pair b) { | ||
return a -- (a.x,b.y) -- b -- (b.x,a.y) -- cycle; | ||
} | ||
|
||
|
||
unitsize(1cm); | ||
|
||
picture[] pics = { | ||
apple.drawing(1.5), rotate(30)*banana.drawing(0.9), strawberry.drawing(), watermelon.drawing(0.9), | ||
tomato.drawing(0.7), rotate(40)*carrot.drawing(0.5), rotate(30)*potato.drawing(0.8), eggplant.drawing(0.9) | ||
}; | ||
|
||
for (int i=0; i<pics.length; ++i) { | ||
pics[i] = shift(-min(pics[i], true))*pics[i]; | ||
pics[i] = shift(-max(pics[i], true)/2)*pics[i]; | ||
} | ||
pics[1] = shift(-0.5,0)*pics[1]; | ||
|
||
int[] foods = {6, 6, 0, 5, 5, 3, 3, 3, 3, 3, 7, 7, 2, 2, 2, 2, 1, 1, 4, 4, 4, 4, 4, 4, 4}; | ||
|
||
real step = 5, width = 0.4; | ||
|
||
add(shift(-13, 3)*reflect((2, 1), (2, 0))*bunny_polychrome.drawing(5, bunny_polychrome.allie_col)); | ||
|
||
filldraw((-step*0.7, -width) -- (0, -width) -- (0, width) -- (-step*0.7, width) -- (-step*1.3, 0) -- cycle, rgb("#da6d42"), rgb("#563232")+5); | ||
for (int i=0; i<foods.length; ++i) { | ||
add(shift(step*i, 0)*pics[foods[i]]); | ||
label(scale(6)*string(i+1), (step*i,-5)); | ||
layer(); | ||
filldraw(rect((step*i+width/3, -width), (step*min(i+1, foods.length-0.4), width)), rgb("#da6d42"), rgb("#563232")+5); | ||
} |
3 changes: 3 additions & 0 deletions
3
src/fibonacci-primarie/2024-seconda-fase/contest/p-2-spiedino/primarie1.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[]{131, 42, 333})); |
3 changes: 3 additions & 0 deletions
3
src/fibonacci-primarie/2024-seconda-fase/contest/p-2-spiedino/primarie2.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[]{76, 73, 357})); |
57 changes: 57 additions & 0 deletions
57
src/fibonacci-primarie/2024-seconda-fase/contest/p-2-spiedino/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,57 @@ | ||
Allie ha preparato un lungo spiedino di 25 gustosi cibi: | ||
|
||
 | ||
|
||
Ora deve determinare il **valore** dello spiedino per portarlo al mercato. Per calcolarlo, deve seguire questo procedimento: | ||
|
||
 | ||
|
||
Quanto è il valore calcolato alla fine di questo procedimento? | ||
|
||
- [ ] 4 | ||
- [x] 8 | ||
- [ ] 12 | ||
- [ ] 18 | ||
- [ ] 25 | ||
|
||
> Ragionando sul programma di Allie, si può vedere che con un ciclo percorre tutti i valori $i$ da $1$ a $24$, | ||
> esaminando per ciascuno se i cibi nelle posizioni $i$ e $i+1$ sono diversi. In altre parole, Allie sta | ||
> esaminando tutte le coppie di cibi vicini, contando quante sono diverse. Questo in pratica conta quanti | ||
> diverse zone di frutta uguale ci sono sullo spiedino, che sono 8: | ||
> | ||
> 1. le due patate; | ||
> 2. la mela; | ||
> 3. le due carote; | ||
> 4. le cinque fette di anguria; | ||
> 5. le due melanzane; | ||
> 6. le quattro fragole; | ||
> 7. le due banane; e infine | ||
> 8. i sette pomodori. | ||
> | ||
>  | ||
>  | ||
--- | ||
|
||
Carol sta pensando che gli piacerebbe cambiare un po' il suo spiedino, di modo che il suo valore aumenti di $5$. | ||
Quanti frutti dovrà modificare al minimo per ottenere questo risultato? | ||
|
||
- [ ] 2 | ||
- [x] 3 | ||
- [ ] 4 | ||
- [ ] 5 | ||
- [ ] 6 | ||
|
||
> Possiamo creare $5$ zone di frutta in più cambiando solo tre frutti. | ||
> Con un singolo frutto possiamo spezzare una zona che sia lunga almeno tre per farla diventare tre zone. | ||
> Questa cosa possiamo farla due volte per aumentare il valore di $4$, per esempio sostituendo | ||
> una fetta di anguria nel mezzo con una patata e una delle fragole nel mezzo con una mela. | ||
> | ||
> A questo punto dobbiamo ancora aumentare il valore di $1$. Questo possiamo farlo sostituendo un cibo | ||
> alla fine della zona con un'altro diverso: per esempio sostituendo una banana con una carota. | ||
> Questo sarebbe il risultato finale: | ||
> | ||
>  | ||
> | ||
>  | ||
>  |
3 changes: 3 additions & 0 deletions
3
src/fibonacci-primarie/2024-seconda-fase/contest/p-2-spiedino/secondarie1.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[]{539, 98, 610})); |
3 changes: 3 additions & 0 deletions
3
src/fibonacci-primarie/2024-seconda-fase/contest/p-2-spiedino/secondarie2.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[]{321, 172, 754})); |
45 changes: 45 additions & 0 deletions
45
src/fibonacci-primarie/2024-seconda-fase/contest/p-2-spiedino/sol.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,45 @@ | ||
access "../../../../asy_library/pictures/bunny_polychrome.asy" as bunny_polychrome; | ||
access "../../../../asy_library/pictures/apple.asy" as apple; | ||
access "../../../../asy_library/pictures/banana.asy" as banana; | ||
access "../../../../asy_library/pictures/strawberry.asy" as strawberry; | ||
access "../../../../asy_library/pictures/watermelon.asy" as watermelon; | ||
access "../../../../asy_library/pictures/tomato.asy" as tomato; | ||
access "../../../../asy_library/pictures/carrot.asy" as carrot; | ||
access "../../../../asy_library/pictures/potato.asy" as potato; | ||
access "../../../../asy_library/pictures/eggplant.asy" as eggplant; | ||
|
||
path rect(pair a, pair b) { | ||
return a -- (a.x,b.y) -- b -- (b.x,a.y) -- cycle; | ||
} | ||
|
||
|
||
unitsize(1cm); | ||
|
||
picture[] pics = { | ||
apple.drawing(1.5), rotate(30)*banana.drawing(0.9), strawberry.drawing(), watermelon.drawing(0.9), | ||
tomato.drawing(0.7), rotate(40)*carrot.drawing(0.5), rotate(30)*potato.drawing(0.8), eggplant.drawing(0.9) | ||
}; | ||
|
||
for (int i=0; i<pics.length; ++i) { | ||
pics[i] = shift(-min(pics[i], true))*pics[i]; | ||
pics[i] = shift(-max(pics[i], true)/2)*pics[i]; | ||
} | ||
pics[1] = shift(-0.5,0)*pics[1]; | ||
|
||
int[] foods = {6, 6, 0, 5, 5, 3, 3, 6, 3, 3, 7, 7, 2, 0, 2, 2, 1, 5, 4, 4, 4, 4, 4, 4, 4}; | ||
|
||
real step = 5, width = 0.4; | ||
|
||
add(shift(-13, 3)*reflect((2, 1), (2, 0))*bunny_polychrome.drawing(5, bunny_polychrome.allie_col)); | ||
|
||
int[] edits = {8, 14, 18}; | ||
for (int x: edits) | ||
filldraw(shift(step*(x-1),0)*rect((-3,-7), (3,4)), lightred, heavyred+5); | ||
|
||
filldraw((-step*0.7, -width) -- (0, -width) -- (0, width) -- (-step*0.7, width) -- (-step*1.3, 0) -- cycle, rgb("#da6d42"), rgb("#563232")+5); | ||
for (int i=0; i<foods.length; ++i) { | ||
add(shift(step*i, 0)*pics[foods[i]]); | ||
label(scale(6)*string(i+1), (step*i,-5)); | ||
layer(); | ||
filldraw(rect((step*i+width/3, -width), (step*min(i+1, foods.length-0.4), width)), rgb("#da6d42"), rgb("#563232")+5); | ||
} |
Oops, something went wrong.