Register for your free account! | Forgot your password?

You last visited: Today at 12:42

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Python task

Discussion on Python task within the General Coding forum part of the Coders Den category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Apr 2010
Posts: 7
Received Thanks: 0
Python task

Hello!

If someone could help me or make me this script i would be really happy since i forgot that i need to make this until tomorow. I can offer league of legends, uplay, netflix accounts in return

Task:
pairs = {("Ana", "Berta"), ("Ana", "Greta"), ("Ana", "Helga"),
("Berta", "Cilka"), ("Berta", "Helga"),
("Cilka", "Dani"),
("Dani", "Ema"), ("Dani", "Greta"), ("Dani", "Helga"),
("Ema", "Fanci"), ("Ema", "Greta"), ("Ema", "Helga"),
("Fanci", "Iva"), ("Fanci", "Jana"), ("Fanci", "Klavdija"),
("Greta", "Helga")}

For simplicity and efficiency, every pair is listed just once, in alphabetic order (e.g. ("Ana", "Berta") and not also ("Berta", "Ana").

The other representation is a dictionary, where keys contain names and the corresponding values are sets of friends.

network = {"Ana": {"Berta", "Greta", "Helga"},
"Berta": {"Ana", "Helga", "Cilka"},
"Cilka": {"Berta", "Dani"},
"Dani": {"Cilka", "Ema", "Greta", "Helga"},
"Ema": {"Dani", "Fanci", "Greta", "Helga"},
"Fanci": {"Ema", "Iva", "Jana", "Klavdija"},
"Greta": {"Ana", "Dani", "Ema", "Helga"},
"Helga": {"Ana", "Berta", "Dani", "Ema", "Greta"},
"Iva": {"Fanci"},
"Jana": {"Fanci"},
"Klavdija": {"Fanci"}
}

The order here is unimportant (actually undefined, since we're dealing with dictionaries and sets). Note that here Berta is listed among Ana's friends and vice versa.
Here is a smaller network that also appears in tests.
Implement the following functions.

1.
• to_map(pairs) gets a list of pairs (like above) and returns a dictionary with the network (like below above).
• to_pairs(network) does the opposite.
• n_friends(network, n) gets a network (the second presentation) and returns a set of names of persons that have exactly n friends.
• lonely(network) returns a set of names of people with only a single friend.
• most_known(network) returns the name of the person with most friends.
• common_friends(network, name1, name2) returns a set of common friends of the two persons.

2.
• by_n_friends(network) returns a dictionary with keys from 1 to len(mreza) - 1 and the corresponding sets of people with that number of friends. For instance, for the small network, the function must return {1: {"D"}, 2: {"A", "B"}, 3: {"C"}}. See the example for the large network in the tests.
• suggestions(network) returns a list of pairs that are not friends but have at least one common friend. The pair must be sorted alphabetically (e.g. ("Ana", "Berta") and not ("Berta", "Ana")).
• clique(network, names) returns True if all persons from the group names know each other, and False otherwise.
• most_commons(network) returns the pair with the most mutual friends.

3.
• strangers(network, names) returns True if the group names contains absolute strangers - not even one pair knows each other -, and False otherwise.
• is_cover(network, names) returns True if the group "covers" the entire network in the sense that every person in the network is either in the group or is a friend with someone in the group.
• triangles(network) computes the number of "triangles" - triplets of people who know each other.

4.
• minimal_cover(mreza) returns the smallest set of names that cover the network (in the sense described at function is_cover, above).

5.
• Write all the above functions in a single line, except for to_dict, to_pairs, minimal_cover, most_known and most_commons. (The latter two are not complicated to write in a single line, but we haven't learned about that yet.)



Thanks
faakr is offline  
Old 12/01/2016, 23:08   #2
 
0xFADED's Avatar
 
elite*gold: 7
Join Date: Dec 2013
Posts: 446
Received Thanks: 187
Quote:
I can offer league of legends, uplay, netflix accounts in return
Maybe you should post this in .
0xFADED is offline  
Reply


Similar Threads Similar Threads
[Python Frage] Python aus Clienten importieren
04/23/2016 - Metin2 Private Server - 16 Replies
Guten Tag. Ich habe eine kleine Frage. Da ich es selber nicht verstehe und mit Python einfach nichts kann, frage ich mal wieder euch lieben, da ihr mir bis jetzt immer geholfen habt. Ich möchte meinen Skript im Spiel testen ohne die .epk und .eix dauernd zu verpacken/entpacken. Deshalb möchte in in die Game.py in der root.epk eine Art Pfad importieren. Das heißt, ich will es ungefähr so machen: https://i.gyazo.com/9875d4bbe00655e4af5efbe19789c e14.png Natürlich ist dies nur ein...
[Buying] LF dutch person for task (GIP) Nederlands(7pages) [WTB] LF dutch person for task (GIP
02/21/2016 - Trading - 1 Replies
Hi i'm looking for a dutch person to make one task for my GIP. I already have 3 pages that i have done myself. In total i need about 10. I have 2examples that you can use. If you have done this before and you're able to this. add my skype to discuss the price and other information. It has to be done asap. __________________
[Python-Modul]EXP-Donator (kompatibel mit Python Loader)
11/23/2013 - Metin2 Hacks, Bots, Cheats, Exploits & Macros - 27 Replies
Moin, da man mich danach gefragt hat und ich sowieso mal ein Beispiel für die Benutzung meines Python Loaders veröffentlichen wollte, habe ich die Gelegenheit genutzt und euch eben einen EXP-Spendebot geschrieben. Man kann ihn einfach mit dem oben verlinkten Python Module Loader laden und ihn mit F5 aktivieren/deaktivieren. Sobald ihr mehr als 99 Erfahrungspunkte habt (man kann nur in 100er Schritten spenden), werden alle Erfahrungspunkte an eure Gilde gespendet. Wer Lust hat und...
Help to make a python file works with python loader
03/03/2013 - Metin2 - 2 Replies
Hey epvp! I want make a very. Little hack works on pythonn loader can anybody help me please?
Metin2 - Python - Wie Python Hacks verschlüsseln und Server überprüfen (GF/PServe)
09/23/2012 - Metin2 - 2 Replies
Ich wollte fragen, wie man Python Hacks am besten Verschlüsselt ? und wie man feststellen kann ob man auf einem GF / Pserver spielt. ?



All times are GMT +1. The time now is 12:42.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2024 elitepvpers All Rights Reserved.