Efficiencie's Posts
Nairaland Forum › Efficiencie's Profile › Efficiencie's Posts
1 2 3 4 5 6 7 8 ... 85 86 87 88 89 90 91 92 93 (of 129 pages)
ypeace:Here is my annoyingly bogus solution to the same problem: https://pastebin.com/JTrSVySJ Please ypeace do you have access or links to ebooks that can ground me python's libraries...not those arcane books that are no different from the python documentation oh! Or alternatively do you know of good books I can buy? I need to grasp python well within a short time...your use of the itertools module there was just delicious! I salute your royal pythoness!
|
I was playing around with some stuff on decision trees and came up with the following problem. I was able to work out a solution but I think my solution may be too slow and I am hoping someone might have a faster alternative. Here is the problem: Design a function that accepts a digit; say 'n', and returns a list of lists of unary digits between 0 and 'n-1', pairs of digits between 0 and 'n-1', triples of digits between 0 and 'n-1', up until the '(n-1)-tuple' digits between 0 and 'n-1'. for example; if n = 2 the function return: [[0], [1], [0, 1]] if n = 3 the function returns: [[0], [1], [2], [0, 1], [0, 2], [1, 2], [0, 1, 2]] if n = 4 the function returns: [[0], [1], [2], [3], [0, 1], [0, 2], [0, 3], [1, 2], [1, 3], [2, 3], [0, 1, 2], [0, 1, 3], [0, 2, 3], [1, 2, 3], [0, 1, 2, 3]] cc ypeace, 4kings, Ajibel, adejumoadeoluwa, melodyogonna, alexis, Nobody and co |
ypeace:Wow! Nice. Thanks for explaining! |
ypeace: # modified: @ypeace, could you please explain how map works in your one-liner!
|
BEGINNER CHALLENGE (copied) Sliding window array multiplication. NOTE < and > symbols in the below surround variable names to indicate you can use your own name in place of what is used in this text, they are not part of the Python syntax. Write a function that returns a list of results of some array multiplications as described below. Your function must accept as parameters two numeric lists, we shall call them <sliding> and <base>, and return one numeric list, <answers>. Note that <sliding> will contain at least as many elements as <base>. Multiply each element in <base> by its corresponding element in sliding: <base>[0] * <sliding>[0], <base>[1] * <sliding>[1], <base>[2] * <sliding>[2] and so on. Add up the results of the above. Store this as your first answer, <answers>[0]. Do it again, but start one element further along in the sliding list. <base>[0] * <sliding>[1], <base>[1] * <sliding>[2], <base>[2] * <sliding>[3] and so on. Add up the results of the above. Store this as your second answer, <answers>[1]. Repeat as many times as you can, storing each answer. You cannot go past the point where <sliding> has fewer elements than <base>. EXTRA MERIT CHALLENGE: Solve in ONE LINE return statement! I already have a one-line solution to this so attempt and lets compare results. See the attached picture for more clarification cc ndizzy, waali, 4kings, lexaydfg, Ihinmi and co
|
...the husband sets fire to his home and the wife doesn't want to be left out of the fun so she orders for a truck of gas-filled cylinders...both the husband and wife sit down to watch their home go up in flames...then they sign papers and go separate ways! Dumb idiots...maintain your baby mama, baby daddy levels and let those who are ready to be committed, sacrificial and godly concern themselves with the affairs of marriage! |
efficiencie:
|
Nothing...after the bride price is paid and the blessings of both parents are bestowed on the marriage they are husband and wife...nowhere in the law of GOD (according to the Bible) is a white wedding prescribed because the blessings of the LORD are upon a marriage that is sanctioned from above, blessed by parents and witnessed by a few! Bible even made us understand that until sex happens the couples are not to be referred to as Husband and Wife... Therefore shall a man leave his father and his mother, and shall cleave unto his wife : and they shall be one flesh. Genesis 2: 24 . As far as GOD is concerned the moment you cleave with a person of the opposite sex you are married to the person and this is why fornication is a deadly sin because it amounts to making a wife out of a woman that you do not intend to marry...or making a husband out of a man you do not intend to marry...this is abuse and GOD hates abuse! |
Write a Python function that prints out the first n rows of Pascal's triangle. for example if n=5 the output must be: 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 where n is a parameter of the function |
busomma:Based on the bolded; have you been BRAINWASHED as well? Because the church and pastor folks all talk about GOD too, much like you do...so concluding your comment with: May God be with ur family looks like you have equally been BRAINWASHED&WIPED. You are recommending proper medication and yet you are saying May God be with ur family ...na which wan yu dey na! Na how proper medication take blend with GOD na? Make up ya mind... |
Ezkid:Your mom is suffering from the after effect of living a life of repeated "unexplainable" (in her perspective) failures...what she needs is your prayers and guidance and not disdain...From your gist, your mom once worked as a hairdresser and while I may be wrong it implies your mom did not SUCCEED in getting formal education (or did she!?). Two, you said your dad took a second wife. That alone can deal a deadly blow to the psyche of a woman who was once the breadwinner of the family. Three, how come your dad is comfortable with a second wife but his earning potential cannot sustain you and your sibs without your mom's help? That shows some sign of irresponsibility and lack of empathy from your dad (though I stand to be corrected)! Last last, there is no smoke without fire...your mom is reacting to something in a manner that makes her a threat to herself and you as her child who now earns should see this as an opportunity to help her heal the pain of the past years which could have resulted in what appears to be a post-traumatic stress disorder which makes her extremely paranoid! I don't easily feel empathy for a man, afterall we all claim to be the stronger sex, but I do feel a lot of empathy for women because the society makes them vulnerable to a truckload of crap and expects them to just soak it up and remain sane! So son, help your mom, she needs you now that your dad is no longer there for her! #modified: After reading some of the posts by some people here...I can confidently assert that there are more insane people on our streets than those in hospitals getting treatment! |
Oh so the Muslims now embrace what some would have considered worldly...fashion week in Saudi Arabia, did the Quran or any of the Hadiths recommend it? Over to the Muslims! |
Holadokun:This is the about the shortest and most sensible comment on this thread...if Nigerians had brains to think like Holadokun we would not have voted in many of the idiots that ruled us thus far! This was how Jonathan crawled out of nowhere and he got support for presidency. See this one na wey suppose first win lagos or any other state governorship election and show his leadership abilities at the state level he wan dey target presidency for wia PhD holders in RIGology dey for both PDP and APC...izzokay o, goodluck! |
Certificate is just a piece of paper...the true worth of a person is in his mind and a well educated mind can do amazing things with 100 million naira! |
From Eve to the 12 year old girls of today one thing is peculiar among them all...they are so easily fascinated and excited by anything that brings them pleasure that they overlook the consequences of their decisions. She is in love with the ex and at the same time was carried away by the wealth of the stranger from no where! I am very sure what she intended to say was that she would like to keep having sex with her ex and probably allow him breed her a couple of times but she would also still like taste of the wealth of the rich dude abroad ...females reek of primitive selfishness! Imagine Eve thinking of how sweet the fruit could be and how she could become as smart as GOD all because a stranger said something contrary to what a known friend said... |
The crap about this feminism thing is that sometimes its proponents push it beyond the limits of sanity, morality and common sense...Yes there is more to life than marriage but yet there is more to life than any single thing, event or achievement. Yet marriage is important in the life of any man or woman. You cannot employ anyone be share the innermost part of you and this is why we need a partner to be a vital source of assistance when life itself becomes a problem...If as a feminist you place rules that your spouse must adhere to then you are equally as CONTROLLING as any non-feminist. What a true partner does it to help his/her spouse become whatever she wishes to be within the boundaries of sanity, morality and functionality...and not sink him/her in the hole of one's personality! |
Are these attackers really HERDSMEN? Every time an attack takes place, they are labelled HERDSMEN is that fair and true? HERDSMEN now have access to military uniform? Wonders will not cease in Nigeria. Some people wey get attack for dream go soon say na HERDSMEN they attack dem! |
Have Nigerians ever hated suffering...Nigerians like suffering! They saw a man literally drunk and they voted for him, they saw a man whose regime witnessed the largest number of political assassinations and plane crashes yet they gave him another term (and would have given him another)...these ones blabbing daily will shut up instantly if they receive money from the powers that be! The reason they are so vocal is because there is nothing they have directly benefited from the government and if the government gives them the take money or die option they will cheerfully accept the former and start praising the government! Rubbish!! |
hopefulLandlord:The above statement, my friend, is laden with INDOCTRINATION. You telling your daughter that morality is subjective and shoving it down her conscience as the truth is the height of INDOCTRINATION. You are no different from the Christians and Muslims who tell their children that GOD exists and that that is the truth. If you really want to repent of hypocrisy and escape INDOCTRINATING your child [which according to you is contrary to your ideals], then you ought to let that child decide for himself/herself what the truth is even at that tender age. That way we can emphatically say you are not INDOCTRINATING your child hopefulLandlord:Do you teach your children this as well? This is a world of INDOCTRINATION as well. I believe your children will be very happy to know that their birth was by accident and they could easily have been a dog or a fly but for the fortunate accident of evolution that made your children become the product of the accidental fusion of an accidental egg and accidental sperm own by people who met accidentally in an accidental world formed accidentally over billions of years ago. This is probably why a lot of people have accidental marriages as well and produce accidental children and hopefully your accidental children will keep up the accidental trend in a world that would most assuredly, according to your most accidental highness, end in an accidental way! No offense. |
efficiencie:I got this problem from a facebook Python group and was able to find a solution for it though my code may not be the faster but any other coder can supply his solution so we can compare and learn. """ This function accepts a single string of comma seperated integers or ranges in any order and converts the string to a sequence of ordered integers """ def string2seq(string): collect = [] for i in string.split(','): try: j = i.split('-') jj = int(j[0]) jjj = int(j[1]) while jj <= jjj: collect += [jj] jj += 1 except: j4 = int(i) collect += [j4] collect.sort() return collect |
Wow! No python enthusiasts here? 4kings, melodyogona, etc where una... |
...but why are Muslims so pained about what Christians believe in? You hardly see a Christian studying the Quran with the intention of arguing with a muslim rather they pray to GOD to do His work but the muslims on the other hand are so interested in making Christianity vanish even if it by using AK47s and rocket propelling guns...The Quran speaks of a day of reckoning, so does the Bible and other scriptures from other religions so why can't we all wait till that time and hear from GOD Himself. We should let GOD defend Himself and cease from defending GOD. GOD knows who He is, that is if I am even permitted to use the pronoun 'HE', and He will explain Himself on that day when He will not be hidden from anyone. So what's the fuss with all the arguments wey dey be like sey some people don ready to kill! Abeg e don do! |
efficiencie:Here is my solution : """ Given a string object word, compute the 'overlapping' frequency of substr excluding the last n(substr) characters of word if word terminates with substr """ def dellast(substr, word): """ delete the last n(substr) characters of the string word if word ends with the substring substr """ j = 0 for i in substr: j += 1 nsubstr = j j = 0 for i in word: j += 1 nword = j j = 0 sub = "" for i in word: j += 1 if j >= nword - nsubstr + 1: sub += i if sub == substr: j = 0 sub = "" for i in word: j += 1 if j <= nword - nsubstr: sub += i return sub else: return word def delfirst(nsubstr, word): """ delete the first nsubstr character(s) of the string word if word ends with the substring substr """ j = 0 sub = "" for i in word: j += 1 if j > nsubstr: sub += i return sub def substrseq(substr, word): """ produce an iterable which is a sequence of substrings of word of lenght nsubstr with each consecutive substring overlapping (i.e each consecutive substring share nsubstr - 1 characters) """ word = dellast(substr, word) j = 0 for i in substr: j += 1 nsubstr = j j = 0 sub = "" while word != "": for i in word: j += 1 sub += i if j == nsubstr: yield sub sub = "" j = 0 break word = delfirst(1, word) def substrcount(substr, word): j = 0 for i in substrseq(substr, word): if substr == i: j += 1 return j def count(substr, word): print("The number of times: \"", substr, "\" occurs in \"", \ word, "\" is: " ) print(substrcount(substr, word)) |
Write a function that converts a string containing an ordered sequence of positive whole numbers and number ranges to an ordered list of those numbers, that it returns. Number are separated with commas (and optional spaces) and number ranges are marked with a - between two whole numbers (with optional spaces either side). For bonus points and handle out of order sequences and reverse ranges. Return an ordered list of unique numbers. State your assumptions (so interpret the challenge your way). For example, ‘1-5, 7, 9, 10-13’ should convert to [1, 2, 3, 4, 5, 7, 9, 10, 11, 12, 13] |
Ugosample:Well for your information, the decline in the consumer price index is DEFLATION. Nevertheless the decline in the inflation rate is not a deflation it is rather a disinflation! |
olujastro:Brilliant response! I am not just happy with you mentioning Okonjo among the three names you mentioned. Okonjo supervised and witnessed first hand the plunder and pillage that was fatal to Nigeria. Nevertheless the Buhari government is quite slow and Nigeria still shows the same structural weaknesses that makes it vulnerable to both local and international shocks. The global financial crisis of 2008 and the fuel price drop of 2015 both revealed that Nigeria cannot stand a shock of a global magnitude and on the local front the so called herdsmen crisis, Boko Haram, organized crime, epileptic power supply, poor health facilities, poor supply of effective high level manpower and poor educational institutions all show that even locally we do not have an necessary fundamentals to foster a market emerging economy. Nigerians expected the government to display an aggressive style of governance towards addressing these ills but from the trajectory we are currently I do not see the Buhari government addressing these issues even in his second tenure. Sadly Buhari does not have a worthy replacement as it was during the last election. |
seguno2:Bro we did not become import dependent in a day. Our human capital is horrible so we do not have the requisite stock of acumen to drive non-oil wealth creation. Our infrastructure is also terrible with emphasis on the security, property right protection, power supply and health facilities which are in short supply. Then to crown it all up we have trade partners who are more sophisticated economically than we are thus ensuring that they reap more of the gains of comparative cost advantage than we do - imagine Nigeria having the US, the UK and China as major trading partners whilst recording very low South-South intra-industry trade where we can reap substantial gains from comparative advantage. These problems have accumulated over the years and only very tough administration can turn the tide and set Nigeria on an economic trajectory headed towards economic independence, resilience and sustainability! And sadly we are yet to have serious, sincere and smart leaders. The crop of politicians I see today, including those who call themselves representatives of the youths, do not have the stuff of tough leaders who can make tough decisions in the interest of Nigeria. Trump may be a madman but his "America first" ideal shows that he is the right madman for America. Nigeria also needs a madman who will put "Nigeria first"! |
AZeD1:I agree with you. A country that relies on its reserves to defend its currency is a structurally imbalanced economy. The failure of our leaders persistently is that they fail to listen to economic experts just so they can continue to steal public funds. The root of economic growth and development is human development plus financial development. When human development in terms of human capital formation and overall wellbeing of the human populace combines with available funds to finance research and development societies develop rapidly...but sadly our leaders are interested in smiling to the bank with billions while all others suffer. Though this administration fared better than the previous , in my opinion, I still say we are yet to get effective and efficient leadership! |
Kingspin:Well the reserves are not good for nothing...the rise in the price level that crippled economic activities in Nigeria for almost two years was occasioned by the scarcity of foreign reserves. Nigeria is still import dependent and if those reserves deplete below the threshold import cover prices will rise again. I am sure you can still remember how you go to the market to buy biscuit at a much higher price only to be told that "dollar don increase"! So you have to thank God that our reserves are back and growing! |
AZeD1:You are actually ignorant of what you speak of. If foreign reserves are to meet import liabilities then they are as well designed to stabilize the value of the naira vis-a-vis the dollar. This is so because if there is a surge in the demand for imports without a corresponding supply of foreign exchange excess demand for foreign exchange will result and this will worsen the value of the naira to the dollar and send us back to the periods of surging consumer price indices! So by having enough foreign exchange to meet import liabilities price stability and hence currency stability is achieved! |
Why should anybody, man or woman, go into a marriage with the hopes of getting prepared to leave at the slightest provocation? Is it not better not to be married at all? Why are couples insincere to each other? Why must couples who at one point were loving each other crazily get to the point where they hate each other so much that they cannot bear to see each other? Why must you marry if you are not ready to sacrifice, be committed and love no matter the circumstance? Because of the self-centeredness of many, marriage has become hoax to be avoided! |
I wana ask; is there any specific and generally acceptable style for writing algorithms (i.e pseudocode specifically)? If there are any resources on the internet that can help please can anyone suggest some. |
1 2 3 4 5 6 7 8 ... 85 86 87 88 89 90 91 92 93 (of 129 pages)

