Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added the netflix budy nada program #58

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions programs/nada_netflix_buddy_programs/README.md
Original file line number Diff line number Diff line change
@@ -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.
7 changes: 7 additions & 0 deletions programs/nada_netflix_buddy_programs/nada-project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name = "nada_netflix_buddy_programs"
version = "0.1.0"
authors = [""]

[[programs]]
path = "src/netflix_buddy.py"
prime_size = 128
40 changes: 40 additions & 0 deletions programs/nada_netflix_buddy_programs/src/netflix_buddy.py
Original file line number Diff line number Diff line change
@@ -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)]
Binary file not shown.
30 changes: 30 additions & 0 deletions programs/nada_netflix_buddy_programs/tests/netflix_buddy_test.yaml
Original file line number Diff line number Diff line change
@@ -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"