HUN

Minden feladat 1-1 pontot ér.

2/1. packing

Amikor utazáshoz pakolunk, sokszor nem fér minden be a táskánkba amit szívesen elvinnénk.

A függvény neve legyen packing, két paramétere legyen:A függvény adja vissza a holmik lista első k elemének az összegét, ahol igaz, hogy az első k+1 elem összege már nagyobb lenne mint meret. (Ha valami már nem fér be a táskába, akkor az annál kevésbé fontos dolgokat már akkor se pakoljuk be, ha azok beférnének.)

2/2. evaluate

Egy íjászverseny végén a kell kiértékelni egy versenyző teljesítményét. Ehhez a evaluate nevű függvény megírása a feladat. A függvény paraméterei:Adott egy függvény, pointvalue, ami kiszámolja egy lövés pontértékét, ha megadjuk a lövés relatív pozícióját a célponthoz képest. Számoljuk ki a versenyző pontját úgy, hogy összeadjuk az összes lövésének az értékét.
import mathdef pointvalue(x,
y):    dist = math.hypot(x, y)    if dist > 10:        return
0    else:        return 10 - int(dist)def evaluate(target, l):
pass #TODO

2/3. product_x

Írjunk python függvényt, ami megmondja a legkisebb számot aminek a számjegyeinek szorzata egy adott szám.

A függvény neve legyen product_x, egy paramétere legyen, az x

A függvény egy egész számmal térjen vissza, ami megfelel a feltételeknek.

Segítség:

2/4. magic_square

A bűvös négyzet alatt általában egy olyan táblázatot értünk, aminek minden sorában, oszlopában ugyanannyi a számok összege. Írjunk függvényt, ami leellenőrzi, hogy egy adott táblázat bűvös négyzet-e.

A függvény neve legyen magic_square, és egy paramétere legyen:A függvény True-val vagy False-al térjen vissza attól függően hogy a táblázatban minden sor és oszlop összege megegyezik-e.

ENG

All problems worth 1-1 point.

2/1. packing

You want to go to a hike and you have more stuff than your backpack.Write a function that decides what to bring along!The function should be called packing and have two parameters:The function should have to return the total volume what you managed to pack.If you pack the first k items then return the sum of their sizes.Adding the next element would exceed the backpack.You don't pack less important stuff even if it would fit better then the more important stuff.

2/2. evaluate

We organise an archery contest and we need a function to evaluate the score of the players.Write a function called evaluate with two parameters:The function pointvalue is already written and calculates the point of a given shot and we have to calculate the sum of the shots to get the total score.

To evaluate one shot you have to call the function pointvalue with the relative coordinates of the target and the current shot.That function calculates the length of that vector (distance from the target) and converts it to points.

What you have to do is to sum up the point values of the list of shots and return the total score.
import mathdef pointvalue(x,
y):    dist = math.hypot(x, y)    if dist > 10:        return
0    else:        return 10 - int(dist)def evaluate(target, l):
pass #TODO

2/3. product_x

For a given number x calculate the smallest positive integerfor which the product of the digits is equal to the original number.

For example if x=12 the number 26 has digits 2 and 6and their product is equal to 12.Also 26 is the smallest number with this property.

Write a function called product_x with one parameter: x. Return the smallest number with this property.

Hint

To do this you need two functions:

2/4. magic_square

Write a function that checks a magic square.A table (list of lists) is a magic square ifIf any of those requirements fail then it is not a magic square.

The function magic_square should have one parameter: the table (list of lists of numbers).The list will not be empty and every element will be a sublist with the same length (square).

Return True if it is a magic square and False otherwise.