We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
#!/bin/python3importmathimportosimportrandomimportreimportsys## Complete the 'viralAdvertising' function below.## The function is expected to return an INTEGER.# The function accepts INTEGER n as parameter.#classPeople:def__init__(self,received):self.received=receivedself.liked=0defcalculate_likes(self):self.liked=self.received// 2returnself.likeddefget_next_day_receivers(self):returnself.liked*3classDay:def__init__(self,day_number,received):self.day_number=day_numberself.people=People(received)defprocess_day(self):likes=self.people.calculate_likes()next_day_receivers=self.people.get_next_day_receivers()returnlikes,next_day_receiversclassAdvertisingCampaign:def__init__(self,total_days):self.total_days=total_daysself.cumulative_likes=0self.initial_receivers=5defrun_campaign(self):current_receivers=self.initial_receiversforday_numberinrange(1,self.total_days+1):day=Day(day_number,current_receivers)likes,next_day_receivers=day.process_day()self.cumulative_likes+=likescurrent_receivers=next_day_receiversreturnself.cumulative_likesdefmain():n=int(input())campaign=AdvertisingCampaign(n)total_likes=campaign.run_campaign()print(total_likes)if__name__=="__main__":main()
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Viral Advertising
You are viewing a single comment's thread. Return to all comments →
My solution using Python.