From c41cabedd02b0fc8fb48a72886baf961bf09f891 Mon Sep 17 00:00:00 2001 From: "alessandro.rabiti" Date: Sat, 29 Mar 2025 02:13:40 +0100 Subject: [PATCH] feat: primo commit, completati primi due esercizi --- 01_compass_calibration/README.md | 109 ++++ .../__pycache__/matrix.cpython-313.pyc | Bin 0 -> 1999 bytes 01_compass_calibration/matrix.py | 601 ++++++++++++++++++ 01_compass_calibration/part1.py | 32 + 01_compass_calibration/part2.py | 36 ++ 01_compass_calibration/part3.py | 44 ++ 02_absurd_arithmetic/README.md | 121 ++++ .../__pycache__/data.cpython-313.pyc | Bin 0 -> 755 bytes 02_absurd_arithmetic/data.py | 104 +++ 02_absurd_arithmetic/part1.py | 26 + 02_absurd_arithmetic/part2.py | 31 + 02_absurd_arithmetic/part3.py | 42 ++ 03_supplies_in_surplus/README.md | 38 ++ .../__pycache__/data.cpython-313.pyc | Bin 0 -> 1777 bytes 03_supplies_in_surplus/data.py | 100 +++ 03_supplies_in_surplus/part1.py | 15 + 16 files changed, 1299 insertions(+) create mode 100644 01_compass_calibration/README.md create mode 100644 01_compass_calibration/__pycache__/matrix.cpython-313.pyc create mode 100644 01_compass_calibration/matrix.py create mode 100644 01_compass_calibration/part1.py create mode 100644 01_compass_calibration/part2.py create mode 100644 01_compass_calibration/part3.py create mode 100644 02_absurd_arithmetic/README.md create mode 100644 02_absurd_arithmetic/__pycache__/data.cpython-313.pyc create mode 100644 02_absurd_arithmetic/data.py create mode 100644 02_absurd_arithmetic/part1.py create mode 100644 02_absurd_arithmetic/part2.py create mode 100644 02_absurd_arithmetic/part3.py create mode 100644 03_supplies_in_surplus/README.md create mode 100644 03_supplies_in_surplus/__pycache__/data.cpython-313.pyc create mode 100644 03_supplies_in_surplus/data.py create mode 100644 03_supplies_in_surplus/part1.py diff --git a/01_compass_calibration/README.md b/01_compass_calibration/README.md new file mode 100644 index 0000000..4d4018d --- /dev/null +++ b/01_compass_calibration/README.md @@ -0,0 +1,109 @@ +# Codyssi - Compass Calibration! + +## Part 1 +Difficulty Rating: 1 + +Following analysis of the data from the drones surveying the Atlantic Ocean, your lab is confident that they’ve located the fabled city of Atlantis! + +Your team has been handpicked for this once-in-a-lifetime research mission. What an honor! Over the course of this trip, you know you’ll be facing a host of natural and supernatural threats. Luckily, your trusty laptop is waterproof, so you should be fine. Probably. + +Soon enough, you and your team find yourselves in a sturdy land vehicle built for all-terrain travel, which will autonomously drive to the beach. There’s just one small issue: the autonomous vehicle isn’t driving itself… + +“Look! It’s the navigation module! It must be faulty…” + +Excellent! That’s not a hard fix: you’ll just have to recalibrate the vehicle’s compass! + +You start the calibration diagnostics: 600 numbers and a long sequence of symbols appear on the monitor. Each number represents a reading in milliradians. + +The first number in the file represents the initial compass offset. However, this isn’t the actual compass offset. + +The following numbers represent the magnitudes (sizes) of the corrections to the initial compass offset. So, the second number corresponds to the first correction, the third number corresponds to the second correction, and so on. + +The sequence of symbols is 599 characters in length and consists of “+” and “-”, representing the sign of each correction. The first symbol corresponds to the first correction, the second symbol corresponds to the second correction, and so on. + +The vehicle’s actual compass offset, measured in milliradians, is calculated by adding all the corrections to the initial compass offset. + +For example, consider this shorter file, with only 10 numbers and 9 symbols: + +8 +1 +5 +5 +7 +6 +5 +4 +3 +1 +-++-++-++ + + +The initial compass offset in this file is 8. The first correction is -1, the second correction is +5, the third correction is +5, and so on. To calculate the actual compass offset, the following calculation is performed: 8-1+5+5-7+6+5-4+3+1 = 21. So, for this shorter input, the actual compass offset is 21 milliradians. + +Now, considering your file, what is the actual compass offset of the vehicle in milliradians? + +(The answer is a number; do not enter ‘milliradians’ as part of your answer.) + +## Part 2 +Difficulty Rating: 1 + +You enter the actual compass offset into the vehicle, and you notice that the navigation system is still faulty. Perhaps you missed something? + +“Oh! The sequence of symbols is stated to be displayed in reverse order!” + +Ah. You’ve missed a key instruction. No worries; it happens to the best of us. + +As the sequence of symbols is in reverse order, the last symbol now corresponds to the first correction, the second-last symbol now corresponds to the second correction, and so on. You’ll still have to determine the actual compass offset by adding all the corrections to the initial compass offset. + +For example, consider the same shorter file: + +8 +1 +5 +5 +7 +6 +5 +4 +3 +1 +-++-++-++ + + +The initial compass offset in this file is still 8; however, some of the corrections have changed! The first correction is now +1, the second correction is +5, the third correction is now -5, and so on. To calculate the actual compass offset now, the following calculation is performed: 8+1+5-5+7+6-5+4+3-1 = 23, and so the actual compass offset is now 23 milliradians. + +Considering your file, what is the new actual compass offset of the vehicle in milliradians? + +## Part 3 +Difficulty Rating: 2 + +You’ve taken a step in the right direction, but the navigation system still seems a little defective! Whatever caused this issue, it better not be another missed instruction… + +Oh, would you look at that, another team member spots another instruction that you somehow missed. This is going great, isn’t it? + +The initial compass offset and all the corrections are meant to be 2-digit numbers! + +The instruction states that the readings are represented by the two numbers on pairs of consecutive lines. This means that the first reading is represented by lines 1 and 2, the second is represented by lines 3 and 4, the third is represented by lines 5 and 6, and so on. + +For each pair of lines, the first number represents the tens digit of the reading, and the second number represents the ones digit of the reading. + +Though, this means that you won’t use all of the symbols in the file. + +For example, consider the same shorter file: + +8 +1 +5 +5 +7 +6 +5 +4 +3 +1 +-++-++-++ + + +Now, the initial compass offset would be 81. The corrections in file order are now +55, +76, -54, and +31. The calculation to find the actual compass offset is now 81+55+76-54+31 = 189. So, the actual compass offset for this file is 189 milliradians. + +Considering your file, what is the actual compass offset in milliradians now? diff --git a/01_compass_calibration/__pycache__/matrix.cpython-313.pyc b/01_compass_calibration/__pycache__/matrix.cpython-313.pyc new file mode 100644 index 0000000000000000000000000000000000000000..b9f396e31b84f0527f58457e9d8c3bcb4f1c7ede GIT binary patch literal 1999 zcmYk7&u$V?6vpp>jdo%;CK_L%A&Lyl0EsctxOUS;mpT?wNeVPGG_gC~_y&ClSH2Hh z6W1iXfaiCq1G7U`2kWB=5QyKokoaF#XM zW#_b8|9KR`D4*tKKFBBbo#rF6%Y10-($-_M3cE&TjT|xXNM*=@`NsaNEK)cZHi(IF zxC*nmQ)B3P#Tn*srWOG~E)aMoZcQytUFw(a9oU*GL;KQY<(24)?#I4@OLh4sW-$RZ zD(@5?8DY>bwis!0;h8~onF5Y#SC)s)K&6^=Peyt}Ah!yb9go7oHB7 zf|<#UYDrV=hjfru=p;T2(C8{v*az(@`V(bl=GC2SV5x)>MDNc6HFXM^8ordrM@5|& zdSNf|P)k}XN*!vDRhp$!r8BM5gchiQI_SXZPrIV7rCr)by&ak!F7FLhv>TcY?a`aO z%B8n}-C<&OpGs+0$gL9sQyob&c3OKyFFNbYjP5$6I>GED{WA+W@X{6asfqUVsOnfC z6w`YMMhb)Bbm)ZAP2#h!^vXU{4F&bPf&NrZE2=Y*&Jq34J9iW!Hz%A^CoNc~-yF_^ zy64V21Wrm6^?4_R-Yb2274TJP3F_!aPAb; zQ4ym)9r%EyDpXd)9$0ouYmebl8vs1&abV711waUBKGBX%^pKU*B$@yj`wmH&^p_jr}tR{*BugcH4EcEZcR?kGn@d RvfcHw(EW1!Gi#14^dCSQEt3EM literal 0 HcmV?d00001 diff --git a/01_compass_calibration/matrix.py b/01_compass_calibration/matrix.py new file mode 100644 index 0000000..2cf8aa3 --- /dev/null +++ b/01_compass_calibration/matrix.py @@ -0,0 +1,601 @@ +n="""4 +9 +5 +1 +8 +8 +9 +4 +5 +5 +3 +1 +5 +8 +7 +3 +2 +3 +4 +7 +4 +8 +8 +1 +1 +5 +6 +9 +1 +7 +7 +9 +1 +6 +8 +2 +9 +4 +4 +5 +1 +1 +8 +3 +8 +3 +2 +1 +3 +2 +4 +9 +3 +5 +3 +7 +7 +9 +3 +6 +8 +9 +2 +2 +1 +9 +1 +4 +9 +8 +9 +8 +4 +9 +9 +6 +2 +3 +7 +3 +5 +9 +8 +1 +2 +8 +2 +3 +3 +9 +4 +6 +5 +1 +7 +4 +9 +5 +7 +5 +1 +8 +4 +1 +1 +4 +9 +5 +8 +1 +8 +7 +2 +2 +6 +7 +9 +9 +4 +7 +3 +9 +5 +2 +9 +7 +3 +4 +1 +1 +8 +9 +4 +5 +8 +7 +2 +5 +1 +3 +5 +9 +3 +8 +4 +7 +2 +8 +2 +6 +6 +9 +6 +8 +7 +5 +7 +5 +1 +1 +9 +3 +9 +8 +2 +4 +8 +1 +8 +3 +6 +4 +3 +8 +2 +1 +4 +7 +7 +9 +6 +3 +3 +8 +3 +8 +3 +1 +7 +6 +3 +8 +1 +3 +2 +3 +7 +9 +2 +6 +3 +7 +2 +4 +6 +2 +7 +2 +8 +6 +9 +5 +5 +3 +2 +7 +8 +3 +3 +4 +7 +9 +9 +3 +7 +5 +5 +7 +1 +8 +4 +4 +2 +5 +8 +9 +5 +2 +5 +4 +5 +6 +5 +1 +2 +4 +7 +8 +9 +6 +6 +5 +4 +3 +1 +6 +2 +6 +4 +8 +9 +2 +5 +4 +6 +3 +1 +8 +2 +8 +7 +5 +9 +4 +1 +4 +9 +5 +7 +3 +5 +6 +6 +9 +8 +7 +2 +3 +5 +6 +4 +8 +8 +2 +5 +9 +9 +7 +1 +9 +3 +4 +9 +9 +8 +9 +6 +7 +2 +5 +7 +6 +1 +3 +6 +1 +3 +7 +3 +7 +1 +2 +8 +3 +8 +7 +6 +9 +1 +4 +9 +8 +1 +4 +1 +5 +8 +2 +7 +7 +2 +6 +8 +7 +1 +5 +6 +4 +4 +9 +8 +6 +6 +2 +9 +6 +4 +9 +8 +7 +7 +9 +4 +4 +9 +3 +6 +7 +3 +6 +9 +3 +3 +4 +6 +2 +3 +7 +2 +3 +4 +2 +3 +3 +6 +5 +5 +4 +4 +7 +4 +8 +5 +3 +8 +1 +3 +2 +7 +2 +5 +1 +2 +4 +4 +7 +7 +9 +5 +3 +1 +8 +7 +2 +6 +5 +8 +8 +7 +3 +9 +9 +3 +3 +6 +1 +5 +2 +2 +4 +5 +4 +8 +1 +3 +3 +2 +4 +4 +2 +7 +1 +1 +7 +8 +5 +1 +2 +4 +7 +4 +7 +9 +6 +3 +5 +2 +6 +5 +5 +6 +7 +2 +3 +4 +5 +4 +3 +7 +2 +9 +5 +7 +6 +6 +3 +5 +1 +3 +5 +4 +1 +1 +1 +6 +7 +4 +5 +5 +5 +2 +4 +1 +7 +3 +4 +8 +2 +7 +5 +7 +3 +9 +7 +1 +1 +3 +9 +4 +1 +8 +2 +7 +9 +2 +2 +7 +5 +6 +8 +7 +7 +1 +4 +3 +7 +6 +3 +6 +5 +7 +5 +7 +3 +1 +9 +4 +7 +5 +9 +7 +4 +2 +3 +8 +8 +9 +6 +4 +5 +5 +8 +8 +9 +6 +1 +7 +9 +6 +8 +2 +8 +2 +4 +9 +5 +4 +9 +3 +6 +3 +7 +4 +6 +8 +9 +1 +7 +8 +7 +4 +1 +5 +8 +7 +2 +8 +1 +7 +3 +1 +7 +2 +1 +8 +9 +3 +4 +5 +2""" +s="""+-------++---+--+++++-----+--++++-+--+-+--++--+++--+-----++--++--++-+++------++-+++--+---+-+++-+-++-+-+-++-+++---+-+++-+-+--++---+-+++--+-++++-+++-+-+-+-+-++-+---+-+-++-+--++-+--+-+---++++-+-----+++-++-++++--+-+++-++++-+-+-+------++++------++----++-++---+---+------+-++-+-+-----+++++++--+++--+-+--+++---++-++--+-+-++--+++--+-----++---++---++--+++++--+----++++--++----+--++----+-++++--++--++---++----+++-+++++--++-++-++---+++--++-++++++++----++--+++-+-+++-+--+++++-+-++-+--+---+---+--+-+--++-++--+-+-++++-+++---+-+-+-+++-+--+-+--++--+--++--++-++++-++-+--+-----++++--++--+---+++-++-+--+--+++-++--++++-""" diff --git a/01_compass_calibration/part1.py b/01_compass_calibration/part1.py new file mode 100644 index 0000000..5b70f1f --- /dev/null +++ b/01_compass_calibration/part1.py @@ -0,0 +1,32 @@ +import importlib.util + +# Import del file con le liste di numeri ed operatori +data = "matrix.py" + +spec = importlib.util.spec_from_file_location("matrix", data) +matrix = importlib.util.module_from_spec(spec) +spec.loader.exec_module(matrix) + +# creo una lista vuota +num = [] + +# per ogni riga della lisa dei numeri estraggo il valore +# mi serve perche' se no prende l'andare a capo come valore +for line in matrix.n.splitlines(): + num.append(line) + +# creo la variabile per sommare i valori +# la definisco con il valore del primo numero +# converto la stringa contenuta nella lista in intero +result = int(num[0]) + +# ciclo insieme tutti i numeri e gli operatori, partendo dal +#secondo numero della lista dei valori +for n, op in zip(num[1:], matrix.s): + if op == '+': + result += int(n) + if op == '-': + result -= int(n) + +#stampo il risultato +print("result =", result) diff --git a/01_compass_calibration/part2.py b/01_compass_calibration/part2.py new file mode 100644 index 0000000..743d1e9 --- /dev/null +++ b/01_compass_calibration/part2.py @@ -0,0 +1,36 @@ +import importlib.util + +# Import del file con le liste di numeri ed operatori +data = "matrix.py" + +spec = importlib.util.spec_from_file_location("matrix", data) +matrix = importlib.util.module_from_spec(spec) +spec.loader.exec_module(matrix) + +# creo una lista vuota +num = [] + +# per ogni riga della lisa dei numeri estraggo il valore +# mi serve perche' se no prende l'andare a capo come valore +for line in matrix.n.splitlines(): + num.append(line) + +# creo la variabile per sommare i valori +# la definisco con il valore del primo numero +# converto la stringa contenuta nella lista in intero +result = int(num[0]) + +#inverto la stringa degli operatori +s_inverted = matrix.s[::-1] + + +# ciclo insieme tutti i numeri e gli operatori (invertiti), partendo dal +#secondo numero della lista dei valori +for n, op in zip(num[1:], s_inverted): + if op == '+': + result += int(n) + if op == '-': + result -= int(n) + +#stampo il risultato +print("result =", result) diff --git a/01_compass_calibration/part3.py b/01_compass_calibration/part3.py new file mode 100644 index 0000000..5cc0a91 --- /dev/null +++ b/01_compass_calibration/part3.py @@ -0,0 +1,44 @@ +import importlib.util + +# Import del file con le liste di numeri ed operatori +data = "matrix.py" + +spec = importlib.util.spec_from_file_location("matrix", data) +matrix = importlib.util.module_from_spec(spec) +spec.loader.exec_module(matrix) + +# creo una lista vuota +num = [] + +# per ogni riga della lisa dei numeri estraggo il valore +# mi serve perche' se no prende l'andare a capo come valore +for line in matrix.n.splitlines(): + num.append(line) + +#inverto la stringa degli operatori +s_inverted = matrix.s[::-1] + +# creo una nuova lista di lunghezza pari alla meta' dei numeri a disposizione +elementi = int(len(num)/2) + +# scorro i tre array, i numeri in posizione pari sono unita', i numeri in +# posizione dispari (faccio per 10) sono decine e poi sommo tutto nella nuova lista +new_num = [0] * elementi +for n, (d, u) in enumerate(zip(num[::2], num[1::2])): + new_num[n] += int(u) + (int(d)*10) + +# creo la variabile per sommare i valori +# la definisco con il valore del primo numero +# converto la stringa contenuta nella lista in intero +result = int(new_num[0]) + +# ciclo insieme tutti i numeri e gli operatori (invertiti), partendo dal +#secondo numero della lista dei valori +for n, op in zip(new_num[1:], s_inverted): + if op == '+': + result += int(n) + if op == '-': + result -= int(n) + +#stampo il risultato +print("result =", result) diff --git a/02_absurd_arithmetic/README.md b/02_absurd_arithmetic/README.md new file mode 100644 index 0000000..40c5833 --- /dev/null +++ b/02_absurd_arithmetic/README.md @@ -0,0 +1,121 @@ +# Codyssi - Absurd Arithmetic! + +## Part 1 +Difficulty Rating: 1 + +You and your team are now on course to the seaside. It’s getting pretty late though, so why not rest? After all, you’ll probably need it. + +You arrive at the nearest hotel. You walk in, and registration goes quite well! + +Well, up until the peculiar payment process. + +The hotel accepts normal currency, but they calculate their prices in exponentialis pecunia. Oddly, its exchange rate to standard currencies increases exponentially. + +Why would anyone ever use this? + +“Don’t worry, we have a machine that converts from exponentialis pecunia to standard currency. I just need the book of room pricings… Here it is… Wait, it’s not here? Oh no…” + +The clerk has lost her pricing book—you’ll have to help her calculate the room prices! + +“There are 3 pricing functions used to calculate room prices. To calculate the price of a room, you start with the quality of the room. First, apply function C, then apply function B, and then apply function A. The resulting value is the one-night price of a room in exponentialis pecunia.” + +To figure out if you’ll have enough money to stay for the night, a good point to start would be to consider the median-quality room. + +You remind yourself that the median is the middle value in a sorted list. + +For example, consider the following list with 11 room qualities and 3 different pricing functions: + +Function A: ADD 495 +Function B: MULTIPLY 55 +Function C: RAISE TO THE POWER OF 3 + +5219 +8933 +3271 +7128 +9596 +9407 +7005 +1607 +4084 +4525 +5496 + + +For these room qualities, the median quality is 5496. Applying function C, you get 166012263936. Applying function B to that result gives you 9130674516480. Finally, applying function A to that result gives 9130674516975. So the one-night price of the median-quality room, in exponentialis pecunia, is 9130674516975. + +Consider the list of 101 room qualities and the 3 pricing functions given to you. What is the one-night price of the median-quality room in exponentialis pecunia? + +(Enter your answer as a single number without commas.) + +## Part 2 +Difficulty Rating: 2 + +When converted to normal currency, that actually seems quite cheap! + +Though, each member of your team will probably need their own rooms, won’t they… + +“Oh, about that, the hotel charges extra fees for booking more than one room. To calculate the total one-night price for many rooms, you first sum all the rooms’ qualities. Then, you apply function C, then B, then A on the sum. This will give you the one-night price of the rooms in exponentialis pecunia.” + +To get a (very, very generous) upper bound estimate of the total price for your team, you decide to calculate the total price of booking all the rooms with even-numbered room qualities for one night. + +For example, consider the same list with 11 room qualities and 3 different pricing functions: + +Function A: ADD 495 +Function B: MULTIPLY 55 +Function C: RAISE TO THE POWER OF 3 + +5219 +8933 +3271 +7128 +9596 +9407 +7005 +1607 +4084 +4525 +5496 + + +The even-numbered room qualities are 7128, 9596, 4084, and 5496. Their sum is 26304, so by applying the 3 pricing functions in the correct order, the total one-night price of booking these rooms is 1000986169836015. + +Considering your file, what is the total one-night price of all the rooms with an even-numbered room quality, in exponentialis pecunia? + +## Part 3 +Difficulty Rating: 2 + +The upper bound still seems quite reasonable! You and your team members choose rooms and pay for your stay—off to a good night’s sleep! + +As the rest of your team members head to their rooms, you notice the clerk bring out an abnormally large pile of paper. She begins to write furiously, and she seems quite stressed. You’ve gotten too curious now… + +“I have to calculate some room prices since, you know, I lost the pricing book. Come to think of it, you calculated your room prices quite quickly… Do you mind helping me out?” + +She won’t get any sleep without your help, so you can’t really say no, can you? + +She explains the situation to you. A client wants to book a room for one night. He can pay at most 15000000000000 exponentialis pecunia, and he wants the highest quality room that he can afford. + +You’ll have to determine the quality of the room that fits the client’s request. + +For example, consider the same list with 11 room qualities and 3 different pricing functions: + +Function A: ADD 495 +Function B: MULTIPLY 55 +Function C: RAISE TO THE POWER OF 3 + +5219 +8933 +3271 +7128 +9596 +9407 +7005 +1607 +4084 +4525 +5496 + + +For this sample file, the highest quality room that the client could afford is 5496. So, the answer for this sample file is 5496. + +Consider the list of the room qualities and the pricing functions given to you. What is the highest-quality room that the client can afford? diff --git a/02_absurd_arithmetic/__pycache__/data.cpython-313.pyc b/02_absurd_arithmetic/__pycache__/data.cpython-313.pyc new file mode 100644 index 0000000000000000000000000000000000000000..26bb8d8b2736bb0227755ae3aebb581fc2838764 GIT binary patch literal 755 zcmX|6818JLbm1ZBX?Yah z09}iOlrEARO1|aa6{FpoKl}Z@-Q)Q=Rro%9{c-tpQdQr}=HFNUT^yfa@u`|ueKoK9 zdOqnV^Jzc5oL!vUe@5!QEn$k#{zOkoS&3bC6jcMo5E52NDMXHxL=v%yBg@%{v!R4@ zrWBKr1_>mVQR1Q@ksNtTfmj$NtR7R6$G?y%WLEsMOgRN3?^P(83uGpld{!mXlu)OR zl0$;MGNsH$fi)6GVUmnqi_l_OaHN)Ahk!|eRB#$(U~)iK%rOPbB2M0sMzDDSuNk96 zBw{j9SwNoDfrtyQ^NaxXks0b)kr41o0R%LYFG`a$WJ3ax6xR$MKpJ{uhTIIB*n^ij z#nJ}0-$P9l`XIqZfdFV9Fd%8M z-C+RC1q}8ixKYXmK#itU-pl2N_nfpGlYj}UDw}ckM0moOE|f!A0}OWdiHVBm$&{4QKOrA literal 0 HcmV?d00001 diff --git a/02_absurd_arithmetic/data.py b/02_absurd_arithmetic/data.py new file mode 100644 index 0000000..114c3b7 --- /dev/null +++ b/02_absurd_arithmetic/data.py @@ -0,0 +1,104 @@ +a = 160 +b = 97 +c = 3 +qr = """7785 +2080 +6554 +6447 +6575 +4626 +7337 +2930 +9889 +2894 +6288 +7679 +5434 +3987 +2069 +6270 +1974 +2328 +7251 +4671 +1948 +4825 +7298 +8749 +1153 +6904 +9938 +1855 +9577 +4850 +7004 +2152 +7829 +4256 +2632 +3849 +9689 +9839 +6538 +1038 +9044 +5371 +6273 +6439 +3902 +4700 +2710 +5647 +1385 +9923 +6336 +4275 +2354 +7509 +5237 +2012 +2051 +6221 +1259 +5379 +3270 +5432 +1577 +7091 +1478 +8347 +6969 +9682 +2686 +2888 +2198 +2276 +5437 +4051 +6935 +6410 +1674 +1217 +4624 +3389 +2138 +8049 +7633 +5545 +4987 +8038 +6979 +3480 +5392 +6344 +1417 +7574 +2089 +7494 +7757 +3655 +8975 +5695 +1038 +1057 +9406""" diff --git a/02_absurd_arithmetic/part1.py b/02_absurd_arithmetic/part1.py new file mode 100644 index 0000000..eee73e8 --- /dev/null +++ b/02_absurd_arithmetic/part1.py @@ -0,0 +1,26 @@ +# importo la funzine per fare la mediana +import statistics +# importo il file con le variabili +import data + +# creo una lista vuota +qrn = [] + +# ciclo tutti i valori dati per popolare la lista +# data la stringa multilinea iniziale +for line in data.qr.splitlines(): + qrn.append(line) + + +#print("Median of data-set is : % s " +# % (statistics.median(qrn))) + +# calcolo la mediana +p_result = statistics.median(qrn) + +# applico le tre funzioni +c_function = int(p_result) ** data.c +b_function = c_function * data.b +a_function = b_function + data.a + +print("Result : ", a_function) diff --git a/02_absurd_arithmetic/part2.py b/02_absurd_arithmetic/part2.py new file mode 100644 index 0000000..2981364 --- /dev/null +++ b/02_absurd_arithmetic/part2.py @@ -0,0 +1,31 @@ +# importo la funzine per fare la mediana +import statistics +# importo il file con le variabili +import data + +# creo una lista vuota +qrn = [] + +# ciclo tutti i valori dati per popolare la lista +# data la stringa multilinea iniziale +for line in data.qr.splitlines(): + qrn.append(line) + +# creo una nuova lista in cui inserisco i valori +# presenti nella lista qrn se dividendoli per 2 +# hanno resto zero +qrn_even = [int(val) for val in qrn if int(val) % 2 == 0] + +# aggiungo una variabile per sommare i valori pari della lista +qrn_even_sum = 0 + +# sommo tutti i valori pari della lista +for x in qrn_even: + qrn_even_sum += x + +# applico le tre funzioni +c_function = qrn_even_sum ** data.c +b_function = c_function * data.b +a_function = b_function + data.a + +print("Result : ", a_function) diff --git a/02_absurd_arithmetic/part3.py b/02_absurd_arithmetic/part3.py new file mode 100644 index 0000000..9ff980a --- /dev/null +++ b/02_absurd_arithmetic/part3.py @@ -0,0 +1,42 @@ +# importo la funzine per fare la mediana +import statistics +# importo il file con le variabili +import data + +# creo una lista vuota +qrn = [] + +# ciclo tutti i valori dati per popolare la lista +# data la stringa multilinea iniziale +for line in data.qr.splitlines(): + qrn.append(line) + +# conto il numero degli elementi della lista +elementi = int(len(qrn)) + +# creo una nuova lista di zeri lunga come qrn +qrn_new = [0] * elementi + +# per ogni valore della lisat calcolo il risultato e lo salvo +# nella nuva lista +for x in range(len(qrn)): + qrn_new[x] = (((int(qrn[x]) ** data.c)) * data.b) + data.a + +# definisco una nuova variabile vuota +value = 0 + +# valore massimo sopra il quale possiamo scartare i risultati +max_pec = 15000000000000 + +# ciclo per ogni valore, se magire del max, esce +# se maggiore dell'attuale valore parziale salvato, sovrascrive +for i in qrn_new: + if int(i) < max_pec: + if int(i) > value: + value = int(i) + +# una volta ottenuto il massimo valore consentito sotto la soglia indicata +# ritorno al valore di partenza +value_orig = round(((value - data.a) / data.b) ** (1/data.c)) + +print("Result : ", value_orig) diff --git a/03_supplies_in_surplus/README.md b/03_supplies_in_surplus/README.md new file mode 100644 index 0000000..4810a29 --- /dev/null +++ b/03_supplies_in_surplus/README.md @@ -0,0 +1,38 @@ +Codyssi - Supplies in Surplus! + +Part 1 +Difficulty Rating: 1 + +After a refreshing night of sleep, you’ve arrived at the seaside! + +There: a wooden Greek warship, complete with masts and sails. That must be the vessel you’ll use for your journey. Oddly, there seem to be very few technological devices on the ship… + +“Ah, you must be the team from the lab! I’m the captain of the vessel ODC-US. My crew will be at your service for your journey to Atlantis. We’ll be setting sail soon, but we’ve received a surplus of supplies from the lab—there’s no way we could load all this onto the ship.” + +Sure enough, there are clearly too many piles of boxes to load onto the ship. You’ll probably only have enough space for essentials, especially since the captain’s crew is also on the ship. + +One of the crewmates hands you an inventory list, and he explains the situation to you. + + + Each box has one number label. Boxes with the same number label contain the same items. + + Each line in the list contains two ranges of numbers. + + Each range of numbers represents the numbers on the boxes in each pile. For example, 3-5 represents a pile with 3 boxes, labelled 3, 4, and 5 respectively. + + +First, you’ll have to figure out the total number of boxes in all of the piles combined. + +For example, consider the (smaller) inventory list below: + +8-9 9-10 +7-8 8-10 +9-10 5-10 +3-10 9-10 +4-8 7-9 +9-10 2-7 + + +The first range, 8-9, contains 2 boxes. The second range, 9-10, contains 2 boxes. The third range, 7-8, contains 2 boxes. The fourth range, 8-10, contains 3 boxes. By continuing this process, we can determine that the total number of boxes (for this file) is 43. + +Considering your file, what is the total number of boxes in all of the piles? diff --git a/03_supplies_in_surplus/__pycache__/data.cpython-313.pyc b/03_supplies_in_surplus/__pycache__/data.cpython-313.pyc new file mode 100644 index 0000000000000000000000000000000000000000..b898f8af4849e94cae3dcf439aed8f60f330012d GIT binary patch literal 1777 zcmX|?y>47Z6vuZHgrbpL@d8tlV%R%#=6p#A2`M!V1!c6vRa(vOt%)ps%y3|E0Jwj)(n=XmOiEFoK>ecwJf<& zj{7iesaC|AZCRD&9$SggTl%QsT(z^kbq|_p8#0UXIL4^z!Bxr}(X4CL&V2x`(@m`o z<(gKq)5WFcpex;6N6YRtJLScn*88BnQfKhq87@Z^_ZI4<`vmo58f|^sHVS&nprCL~ zFH?;TT77KXOHmta0MHtbd3=Kvkt);~S!S-sjAschFJr>elx**NGC<=J zb%H)7tF6h{DxWrI(0c=Puajl!QW(J*eGVwGVjCmmTFuCl(zKRst0QSiafw(hD-&8D zWyscKvYo+VAVm7p#MPMC6)LTW}&ds4Km~lx>0n2L>Pw1WSCgnh!Deg&oXeObYa+zBvOp>7$2&o*@Qdx`Jlak z)_5OGLBxziU5!_=J42ntNgwtl-8{ElEgc?OW*+(StDhYgck<$w^Ld9ApP&q~-FQ!Ch z=@UGJK^h8{L~d%C~9 zy}G