From 04725e2eb0e5b356acee67d23f7ea4914baa78e0 Mon Sep 17 00:00:00 2001 From: ssd39 Date: Sun, 7 Jul 2024 01:32:08 +0530 Subject: [PATCH] feat: added the netflix budy nada program --- .../nada_netflix_buddy_programs/README.md | 14 ++++++ .../nada-project.toml | 7 +++ .../src/netflix_buddy.py | 40 ++++++++++++++++++ .../target/netflix_buddy.nada.bin | Bin 0 -> 6993 bytes .../tests/netflix_buddy_test.yaml | 30 +++++++++++++ 5 files changed, 91 insertions(+) create mode 100644 programs/nada_netflix_buddy_programs/README.md create mode 100644 programs/nada_netflix_buddy_programs/nada-project.toml create mode 100644 programs/nada_netflix_buddy_programs/src/netflix_buddy.py create mode 100644 programs/nada_netflix_buddy_programs/target/netflix_buddy.nada.bin create mode 100644 programs/nada_netflix_buddy_programs/tests/netflix_buddy_test.yaml diff --git a/programs/nada_netflix_buddy_programs/README.md b/programs/nada_netflix_buddy_programs/README.md new file mode 100644 index 00000000..bb0d455a --- /dev/null +++ b/programs/nada_netflix_buddy_programs/README.md @@ -0,0 +1,14 @@ +# Netflix Buddy + +If you and your friend want to see if you both are Netflix buddies without revealing your content category choices, use Netflix Buddy. + +Rate the following categories on a scale of 1-5 according to your likes: + +- Drama +- Action +- Horror +- Romance +- Thriller +- Comedy + +Blind compute will output your match score on a scale of 0-100. diff --git a/programs/nada_netflix_buddy_programs/nada-project.toml b/programs/nada_netflix_buddy_programs/nada-project.toml new file mode 100644 index 00000000..c30c3f39 --- /dev/null +++ b/programs/nada_netflix_buddy_programs/nada-project.toml @@ -0,0 +1,7 @@ +name = "nada_netflix_buddy_programs" +version = "0.1.0" +authors = [""] + +[[programs]] +path = "src/netflix_buddy.py" +prime_size = 128 diff --git a/programs/nada_netflix_buddy_programs/src/netflix_buddy.py b/programs/nada_netflix_buddy_programs/src/netflix_buddy.py new file mode 100644 index 00000000..c5de4ba4 --- /dev/null +++ b/programs/nada_netflix_buddy_programs/src/netflix_buddy.py @@ -0,0 +1,40 @@ +from nada_dsl import * + +def nada_main(): + party1 = Party(name="Party1") + party2 = Party(name="Party2") + + dramaP1 = SecretInteger(Input(name="DramaP1", party=party1)) + actionP1 = SecretInteger(Input(name="ActionP1", party=party1)) + horrorP1 = SecretInteger(Input(name="HorrorP1", party=party1)) + romanceP1 = SecretInteger(Input(name="RomanceP1", party=party1)) + thrillerP1 = SecretInteger(Input(name="ThrillerP1", party=party1)) + comedyP1 = SecretInteger(Input(name="ComedyP1", party=party1)) + + dramaP2 = SecretInteger(Input(name="DramaP2", party=party2)) + actionP2 = SecretInteger(Input(name="ActionP2", party=party2)) + horrorP2 = SecretInteger(Input(name="HorrorP2", party=party2)) + romanceP2 = SecretInteger(Input(name="RomanceP2", party=party2)) + thrillerP2 = SecretInteger(Input(name="ThrillerP2", party=party2)) + comedyP2 = SecretInteger(Input(name="ComedyP2", party=party2)) + + div = Integer(0) + ans = Integer(0) + + u1 = [dramaP1, actionP1, horrorP1, romanceP1, thrillerP1, comedyP1] + u2 = [dramaP2, actionP2, horrorP2, romanceP2, thrillerP2, comedyP2] + + #checks the difference between choice and calculates the score + for x in range(6): + t = u1[x] - u2[x] + if t < Integer(0): + t = t * Integer(-1) + ans = ans + t + if u1[x] > Integer(0) or u2[x] > Integer(0): + div = div + Integer(5) + + # using finite field method to divide the ans and calculate percentage + inverse_mod = (div ** (Integer(29))) % Integer(31) + result = Integer(100) - ((ans * Integer(7) * inverse_mod) % Integer(31)) + + return [Output(result, "buddy_score", party1), Output(result, "buddy_score", party2)] \ No newline at end of file diff --git a/programs/nada_netflix_buddy_programs/target/netflix_buddy.nada.bin b/programs/nada_netflix_buddy_programs/target/netflix_buddy.nada.bin new file mode 100644 index 0000000000000000000000000000000000000000..1447b05ec1f9720e994dbefca9134fa19335149d GIT binary patch literal 6993 zcmb_g&5ImG6dw~~%qGT3)Sw5k+@Q=PyE5H9AKT(e)DR2?Y}A7gmZhh=dbe?=XX)vQ zSudWw&Bgz~yC?CiXNA4`jh_fcl!zio!1t=&>*?8@sh+?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Z*?+nsRTv%EPWu#yC{Wz)BpIs8rcGL}~SQqLLT}%AF zTwm4)>gD=mggtA74I|W$P~U&SnAc^H%Is>A$t{`It|mL9j4ru#u71h37rA;53?#?pw9-)qhW$?|JdBg*8qbv8^uce_RqKKUGkD1-$= zR~8m~8o{0piy48}>Ddqz7Bd8eWsVjc7BdEiWe!Ll7Bfm7mN_sK7BdL%CTDv@hbF!O zVc|S!P!=S^>6dEg$by&GDaBR@O#0i=Vww6R=0Ob zmuQfRn<7p`>L**W)~0HN6)6KPN7nV58)8+AZ0HpOeu*Ra_*}tjx`g2;Y{&?OF8{u2 zX}97xU%3{4FN&-Ps3kq0Gd1c0R8w+A@$IyzP=ybFFXo&rDu(C9Xc#A3B8rnZlhDat zDEczn9)uzrfWvOYp;W#@b*8)|c4QjJB=fhV(lJhM$aE+-`@p&`YAEl*1p#GMmsi`Z z*X!b`Tmy#;PUUdaLvQdvxKgcyH)}PNIB`&?4u1+V_F<7dP|rtcBCfwW%CMSi@D;IK RxRB+EZq--B0>kY3#{V!HH7Ni9 literal 0 HcmV?d00001 diff --git a/programs/nada_netflix_buddy_programs/tests/netflix_buddy_test.yaml b/programs/nada_netflix_buddy_programs/tests/netflix_buddy_test.yaml new file mode 100644 index 00000000..a3214066 --- /dev/null +++ b/programs/nada_netflix_buddy_programs/tests/netflix_buddy_test.yaml @@ -0,0 +1,30 @@ +--- +program: netflix_buddy +inputs: + RomanceP2: + SecretInteger: "3" + HorrorP2: + SecretInteger: "3" + ActionP1: + SecretInteger: "3" + ThrillerP1: + SecretInteger: "3" + ComedyP2: + SecretInteger: "3" + RomanceP1: + SecretInteger: "3" + HorrorP1: + SecretInteger: "3" + DramaP2: + SecretInteger: "3" + ActionP2: + SecretInteger: "3" + ComedyP1: + SecretInteger: "3" + DramaP1: + SecretInteger: "3" + ThrillerP2: + SecretInteger: "3" +expected_outputs: + buddy_score: + SecretInteger: "3"