Corrected exercise from france ioi python.
- ✧ LEVEL 1 ✧
- Level 1-1 – Text display, sequence of instructions
- Level 1-2 – Repetitions of instructions
- Level 1-3 – Calculations and discovery of variables
- Level 1-4 – Reading the entry
- Level 1-5 – Tests and requirements
- Level 1-6 – Advanced structures
- Level 1-7 – Advanced conditions, Boolean operators
- Level 1-8 – Conditioned repetitions
- 1) Hello world!
- 2) Presentation
- 3) Map of the mountain
- 4) In the thicket
- 5) Stack of cylinders
- 6) Secret recipe
print("Hello world!")
print("Coucou !")
print("Je m'appelle Camthalion")
print("Ma devise est 'Parler peu mais parler bien'.")
print("Tout droit tu grimperas,")
print("La clé tu trouveras,")
print("Habile tu seras,")
print("Quand tu les porteras,")
print("Et avec le chef tu reviendras !")
from robot import *
haut()
haut()
haut()
droite()
droite()
bas()
bas()
droite()
deplacer(1, 3)
deplacer(1, 2)
deplacer(3, 2)
deplacer(1, 3)
deplacer(2, 3)
deplacer(2, 1)
deplacer(3, 2)
deplacer(1, 3)
deplacer(2, 3)
deplacer(1, 2)
deplacer(3, 1)
deplacer(3, 2)
deplacer(1, 3)
deplacer(2, 1)
deplacer(3, 1)
deplacer(3, 2)
deplacer(1, 2)
deplacer(1, 3)
deplacer(2, 3)
deplacer(2, 1)
deplacer(3, 2)
deplacer(3, 1)
deplacer(2, 1)
deplacer(2, 3)
deplacer(1, 2)
deplacer(1, 3)
deplacer(2, 3)
deplacer(1, 2)
deplacer(3, 2)
deplacer(3, 1)
deplacer(2, 1)
deplacer(2, 3)
deplacer(1, 2)
deplacer(1, 3)
deplacer(2, 3)
from robot import *
remplir(5)
transferer(5, 3)
vider(3)
transferer(5, 3)
remplir(5)
transferer(5, 3)
- 1) Punishment
- 2) Basic math
- 3) Water transportation
- 4) The secret of Goma
- 5) Sisyphus
- 6) Writing page
- 7) Checkers game
- 8) Mount Kailash
- 9) Harvest
- 10) The Big Event
for i in range(135):
print("Je dois respecter le Grand Sorcier.")
for loop in range(13):
print("9 * 8 = 72")
from robot import *
gauche()
gauche()
print("Bonjour, laissez-moi vous aider")
ramasser()
for loop in range(32):
droite()
deposer()
from robot import *
for loop in range(15):
droite()
ramasser()
droite()
deposer()
from robot import *
for loop in range(21):
haut()
droite()
for loop in range(21):
gauche()
bas()
for i in range(30):
print("a_", end = "")
print()
for i in range(30):
print("b_", end = "")
print()
for i in range(30):
print("c_", end = "")
for loop in range(20):
for loop in range(20):
print("OX", end = "")
print()
for loop in range(20):
print("XO", end="")
print()
for loop in range(20):
for loop in range(20):
print("OX", end = "")
print()
for loop in range(20):
print("XO", end="")
print()
from robot import *
for loop in range(20):
for rammaser in range(1):
ramasser()
for pas_droite in range(15):
droite()
for deposer_raisain in range(1):
deposer()
for pas_gauche in range(15):
gauche()
from robot import *
for loop in range(9):
haut()
droite()
for howcompt in range(4):
for b in range(8):
bas()
for d in range(1):
droite()
for h in range(8):
haut()
for d in range(1):
droite()
for b in range(9):
bas()
for finish in range(9):
gauche()
- 1) Answer!
- 2) The eclipse
- 3) Candy for everyone!
- 4) Algoreathlon
- 5) Playground
- 6) A game of hide and seek
- 7) Progress by error
- 8) Rocket take off
- 9) Invasion of batrachians
- 10) Fair
- 11) Race with the kids
- 12) Construction of a pyramid
- 13) Multiplication table
print(42)
print(12581 - 11937)
print((25 + 30 + 27 + 22 - 8) * 3)
a = 2
b = 34
c = 6
print((a + b + c), end =" ")
print((a + b + c) * 2, end =" ")
print((a + b + c) * 3, end =" ")
c = 108
print(c * 108)
print(c * 4)
for loop in range(100):
print(loop + 1)
print("J'arrive !")
print("V")
print("V")
print("I")
print("I")
print("V")
print("I")
print("I")
for comptage in range(100,-1,-1):
print(comptage)
print("Décollage !")
crapauds = 1337
for loop in range(12):
crapauds = crapauds * 2
print(crapauds)
tir = 1
bonbon = 0
for loop in range(50):
bonbon = bonbon + tir
print(bonbon)
tir = tir + 1
from robot import *
i = 1 # compteur.
n = 1
# nombre de fois gauche/droite.
while i < 11: # boucle (while) tourne 10 fois.
for y in range(n):
droite()
for e in range(1):
ramasser()
for y in range(n):
gauche()
for e in range(1):
deposer()
n += 1
i += 1
c = 0
for i in range(1):
c = 17**3
c = c + 15**3
c = c + 13**3
c = c + 11**3
c = c + 9**3
c = c + 7**3
c = c + 5**3
c = c + 3**3
c = c + 1**3
print(c)
for j in range(1, 21):
for c in range(1, 21):
print(j * c, end= ' ')
print()
- 1) Harvests
- 2) Spiritual retreat
- 3) Age of grandchildren
- 4) More punishments
- 5) Graduation of thermometers
- 6) Mental math game
- 7) The Great Sale
- 8) Livestock
- 9) Pedestals for statues
- 10) The most beautiful Karva
lg = int(input(""))
mc = 23 * lg * lg
print(mc)
jours = int(input())
nombreH = jours * 16
nombreM = nombreH * 60
nombreS = nombreM * 60
print (nombreS)
ageCadet = int(input())
ageAine = int(input())
difference = ageAine - ageCadet
print(difference)
x = int(input())
for i in range(x):
print("Je dois suivre en cours")
tempMin = int(input())
tempMax = int(input())
for i in range(tempMin, tempMax+1):
print(i)
tempMin = int(input())
tempMax = int(input())
for i in range(tempMin, tempMax+1):
print(i)
positionDepart = int(input())
largeurEmplacement = int(input())
nbVendeurs = int(input())
for i in range(nbVendeurs + 1):
print(positionDepart + largeurEmplacement * i)
nbkarvas = 0
for i in range(20):
nbkarvas = nbkarvas + int(input())
print(nbkarvas)
socle = 0
largeursol = int(input())
largeurface = int(input())
for i in range(largeurface, largeursol + 1):
etage = i * i
socle += etage
print(socle)
nbkarvascomp = int(input()) # nombres de karvas
for i in range(nbkarvascomp): #
poinds = int(input())
age = int(input())
long_des_cornes = int(input())
hauteur_au_garot = int(input())
print(long_des_cornes * hauteur_au_garot + poinds)
- 1) Baggage transportation
- 2) Kilometer markers
- 3) Decreasing prices
- 4) All-out brawl
- 5) Boat price
- 6) Crossing the bridge
- 7) Tug of war contest
- 8) Village password
nbpaquets = int(input())
poids_paquets = int(input())
poids_total = nbpaquets * poids_paquets
if poids_total > 105:
print("Surcharge ! ")
debutnombre = int(input())
finnombre = int(input())
if finnombre - debutnombre >= 0:
print(finnombre - debutnombre)
elif debutnombre - finnombre >= 0:
print(debutnombre - finnombre)
heure_arrivé = int(input())
list_prix = [10, 15, 20, 25, 30, 35, 40, 45, 50, 53, 53, 53, 53]
if heure_arrivé == heure_arrivé:
print(list_prix[heure_arrivé])
supArignon = int(input())
supEvaran = int(input())
if supArignon - supEvaran > 10:
print("La famille Arignon a un champ trop grand")
elif supEvaran - supArignon > 10:
print("La famille Evaran a un champ trop grand")
age_personne = int(input())
if age_personne >= 21:
print("Tarif plein")
elif age_personne < 21:
print("Tarif réduit")
de_1 = int(input())
de_2 = int(input())
somme_de = de_1 + de_2
if somme_de >= 10:
print("Taxe spéciale !")
print(36)
else:
print("Taxe régulière")
print(de_1 * 2 + de_2 * 2)
nbMembres = int(input())
equipe_1 = 0
equipe_2 = 0
for i in range(nbMembres):
equipe_1 += int(input())
equipe_2 += int(input())
if equipe_1 > equipe_2:
print("L'équipe 1 a un avantage")
else:
print("L'équipe 2 a un avantage")
print("Poids total pour l'équipe 1 :", equipe_1)
print("Poids total pour l'équipe 2 :", equipe_2)
secre_code = int(input())
if secre_code == 64741:
print("Bon festin !")
if secre_code != 64741:
print("Allez-vous en !")
- 1) Towns and villages
- 2) Schedule for the day
- 3) Longest stage
- 4) Calculation of height differences
- 5) Type of trees
- 6) Hostel prices
- 7) Protection of the village
- 8) The right price
nblieux = int(input())
villes = 0
for i in range(nblieux):
nbpopulation = int(input())
if nbpopulation > 10000:
villes += 1
print(villes)
posactuelle = int(input())
nbvillages = int(input())
villagesproche = 0
for i in range(nbvillages):
posvillages = int(input())
distance = posactuelle - posvillages
if abs(distance) <= 50:
villagesproche += 1
print(villagesproche)
nbjourdemarche = (int(input()))
maxdistance = 0
for i in range(nbjourdemarche):
distanceparcouru = int(input())
if maxdistance < distanceparcouru:
maxdistance = distanceparcouru
print(maxdistance)
nbmonte_descend = int(input())
variation_altitude_descente = 0
variation_altitude_descente_pos = 0
variation_altitude_montante = 0
for i in range(nbmonte_descend):
variation_altitude = int(input())
if variation_altitude > 0:
variation_altitude_montante += variation_altitude
elif variation_altitude < 0:
variation_altitude_descente += variation_altitude
variation_altitude_descente_pos = abs(variation_altitude_descente)
print(variation_altitude_montante)
print(variation_altitude_descente_pos)
hauteur = int(input())
nbfolioles = int(input())
if hauteur <= 5 and nbfolioles >= 8:
print("Tinuviel")
elif hauteur >= 10 and nbfolioles >= 10:
print("Calaelen")
elif hauteur <= 8 and nbfolioles <= 5:
print("Falarion")
elif hauteur >= 12 and nbfolioles <= 7:
print("Dorthonion")
age = int(input())
poid = int(input())
if age == 60:
print(0)
elif age < 10:
print(5)
else:
if poid >= 20:
print(30 + 10)
else:
print(30)
nbmaisons = int(input())
pos_x_min = 1000000
pos_y_min = 1000000
pos_x_max = 0
pos_y_max = 0
for i in range(nbmaisons):
pos_x = int(input())
pos_y = int(input())
if pos_x < pos_x_min:
pos_x_min = pos_x
if pos_x > pos_x_max:
pos_x_max = pos_x
if pos_y < pos_y_min:
pos_y_min = pos_y
if pos_y > pos_y_max:
pos_y_max = pos_y
print(2 * (pos_x_max - pos_x_min + pos_y_max - pos_y_min))
nbMarchands = int(input())
minPrix = 1000 * 1000
posMinPrix = -1
pos = 1
for loop in range(nbMarchands):
prix = int(input())
if prix <= minPrix:
minPrix = prix
posMinPrix = pos
pos = pos + 1
print(posMinPrix)
- 1) Alien Spy
- 2) Spy House
- 3) Number of days in the month
- 4) Friendship between guards
- 5) Number of people at the party
- 6) Fire stations
- 7) Missing person
- 8) The Big Party
- 9) The spy is unmasked!
- 10) Color areas
date_debut = int(input())
date_fin = int(input())
nbEntrees = int(input())
nb_de_personne_entree = 0
for personne in range(nbEntrees):
date = int(input())
if date >= date_debut and date <= date_fin:
nb_de_personne_entree += 1
print(nb_de_personne_entree)
abs_min = int(input())
abs_max = int(input())
ord_min = int(input())
ord_max = int(input())
nombre_ttl_maison = int(input())
maisons_dans_la_zone = 0
for maison in range(nombre_ttl_maison):
abs = int(input())
ord = int(input())
if abs >= abs_min and abs <= abs_max and ord >= ord_min and ord <= ord_max:
maisons_dans_la_zone += 1
print(maisons_dans_la_zone)
mois = int(input())
if mois >= 1 and mois <= 3 or mois >= 7 and mois <=9: # tranche de mois | 1 to 3 - 7 to 9.
print(30)
elif mois >= 4 and mois <= 6 or mois == 10: # tranche de mois | 4 to 6 - 10.
print(31)
else: # si tout est faux print 29.
print(29)
date_debut_sld1 = int(input())
date_fin_sld1 = int(input())
date_debut_sld2 = int(input())
date_fin_sld2 = int(input())
if date_fin_sld1 < date_debut_sld2 or date_fin_sld2 < date_debut_sld1:
print("Pas amis")
else:
print("Amis")
nbPersonnes = int(input())
nbMax = 0
nbActuel = 0
for loop in range(nbPersonnes * 2):
numero = int(input())
if numero > 0:
nbActuel = nbActuel + 1
else:
nbActuel = nbActuel - 1
if nbActuel > nbMax:
nbMax = nbActuel
print(nbMax)
nbPaires = int(input())
for loop in range(nbPaires):
xMin1 = int(input())
xMax1 = int(input())
yMin1 = int(input())
yMax1 = int(input())
xMin2 = int(input())
xMax2 = int(input())
yMin2 = int(input())
yMax2 = int(input())
if ( (xMax2 <= xMin1) or (xMax1 <= xMin2) ) or ( (yMax2 <= yMin1) or (yMax1 <= yMin2) ):
print("NON")
else:
print("OUI")
numeroPersonne = int(input())
tailleListe = int(input())
estSorti = False
for loop in range(tailleListe):
numero = int(input())
if numero == numeroPersonne:
estSorti = True
if estSorti:
print("Sorti de la ville")
else:
print("Encore dans la ville")
espionDebut = int(input())
espionFin = int(input())
nbInvites = int(input())
nbSuspects = 0
for loop in range(nbInvites):
debut = int(input())
fin = int(input())
if not( (espionFin < debut) or (fin < espionDebut) ):
nbSuspects = nbSuspects + 1
print(nbSuspects)
- 1) Department of Medicine: control of an epidemic
- 2) Administration: annual accounts
- 3) Department of Pedagogy: "it's more, it's less"
- 4) Department of Architecture: construction of a pyramid
- 5) Department of chemistry: explosive mixture
x = int(input())
malade = 1
jour = 1
while malade < x:
malade = malade * 3
jour += 1
print(jour)
somme = 0
T = True
while T:
x = int(input())
if x == -1:
T = False
else:
somme = somme + x
print(somme)
nbessai = 0
nbtrouve = int(input())
nbjoueur = None
while nbjoueur != nbtrouve:
nbjoueur = int(input())
nbessai += 1
if nbjoueur < nbtrouve:
print("c'est plus")
elif nbjoueur > nbtrouve:
print("c'est moins")
print("Nombre d'essais nécessaires :")
print(nbessai)
nbmaxpierres = int(input())
hauteur = 0
nbpierres = 0
while nbpierres + (hauteur + 1) ** 2 <= nbmaxpierres:
hauteur += 1
nbpierres += hauteur ** 2
print(hauteur)
print(nbpierres)
nbtotomesure = int(input())
temperatuemin = int(input())
maxautorise = int(input())
i = 0
while i < nbtotomesure:
temp = int(input())
if temp < temperatuemin or temp > maxautorise:
print("Alerte !!")
break
else:
print("Rien à signaler")
i += 1
Well done you have finished level 1 !! Level 2