₦airaland Forum

Welcome, Guest: Register • Login • With Google • Trending • Recent • New

Stats: 3,344,229 members, 8,510,789 topics. Date: Saturday, 31 October 2026 at 05:34 AM

Toggle theme

Cbrass's Posts

Nairaland Forum › Cbrass's Profile › Cbrass's Posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 (of 179 pages)

Programming › Please I Need Help With This Array by cbrass(op): 12:52pm On Oct 04, 2021
Array
(
[A.txt] => 72
[B.txt] => 27
[C.txt] => 12
)
This is what I want to do:
1 sum all those values and give them to the first key which is [A.txt].
2. remove the [A.txt] then sum [b.txt] and [C.txt] then give the value to key [B.txt].
3 Remove [A.txt],[B.txt] then sum whatever is left and give it to [C.txt].

so that my result will look like this

Array
(
[A.txt] => 111,
[B.txt] => 39,
[C.txt] => 12
)
Language: PHP
Thanks a lot.
Programming › Re: Please Have You Seen This Algorithm Question by cbrass(op): 9:06pm On Oct 03, 2021
stanliwise:
I am not clear of your code and looking at it I don't see how it would solve your problems.

The only thing to consider now is that your questions should not have what we call circular-reference.

So no file now must link to another file that link back to it self. you need a code to do that checking. that been said a simple pseudocode should do.

Please flip your phone horizontally to see the codes properly.


#check for circular reference and ensure none exist

it gives thesame answer as this code I posted before

#this stack will be a global variable to track all opened file and ensure it was not opened twice.
$stack = [];

find_sum($file_path){
global $stack;
$sum = 0;
$values = []
fill $values with all the lines from $file_path

foreach($values as $a_value){

if (it is a number) {
$sum += $a_value;
}
elseif( it is a file_path) {
#check for circular references
if($file_path is in $stack){
die('Error: Circular Reference Encountered');
} else {
#add the file path to stack as already opened
$stack[] = $a_value;

#use the recursion concept
$sum += file_sum($a_value);
}
}
}

return $sum;
}
Programming › Re: Please Have You Seen This Algorithm Question by cbrass(op): 8:20pm On Oct 03, 2021
stanliwise:
I am not clear of your code and looking at it I don't see how it would solve your problems.

The only thing to consider now is that your questions should not have what we call circular-reference.

So no file now must link to another file that link back to it self. you need a code to do that checking. that been said a simple pseudocode should do.

Please flip your phone horizontally to see the codes properly.


#check for circular reference and ensure none exist

#this stack will be a global variable to track all opened file and ensure it was not opened twice.
$stack = [];

find_sum($file_path){
global $stack;
$sum = 0;
$values = []
fill $values with all the lines from $file_path

foreach($values as $a_value){

if (it is a number) {
$sum += $a_value;
}
elseif( it is a file_path) {
#check for circular references
if($file_path is in $stack){
die('Error: Circular Reference Encountered');
} else {
#add the file path to stack as already opened
$stack[] = $a_value;

#use the recursion concept
$sum += file_sum($a_value);
}
}
}

return $sum;
}
I did something similar to this before, when i get home i will try yours. Thanks a lot i really appreciate it
Programming › Re: Please Have You Seen This Algorithm Question by cbrass(op): 8:16pm On Oct 03, 2021
Iambro:
Create a recursive function that read the files or check if it is a directory then reads its files etc.
I have done that, it didn't give the desired answer..one thing is this question looks so easy but when you start to code then you will get hooked somewhere
Programming › Re: Please Have You Seen This Algorithm Question by cbrass(op): 11:41pm On Oct 02, 2021
fnep2smooth:
Are you looking for job in Google or Facebook. If na naija company expect to be pay 30k with a intern tag.
grin grin grin grin this made my day after serious coding to solve the problem
Programming › Re: Please Have You Seen This Algorithm Question by cbrass(op): 11:40pm On Oct 02, 2021
stanliwise:
Share your code.
It’s straight forward
function fileSum($file) {
return array_sum(array_map(function($val) {
$val = trim($val);
if (is_numeric($val)) {
return $val;
}
return fileSum($val);
}, file($file)));
}

echo fileSum('a.txt');
This code loops through all the files and sums them for just file A.
instead of breaking it by file just as the example given
Programming › Please Have You Seen This Algorithm Question by cbrass(op): 4:06pm On Oct 02, 2021
Write a production-ready function in PHP that sums the numbers in a file and outputs details of the results. The function will receive as input the path to a single file. Each line of the file will contain either a number or a relative path to another file. For each file processed, output the file path and the sum of all of the numbers contained both directly in the file and in any of the sub files listed in the file (and their sub files, etc).



For example, if file A.txt contains:

3
19
B.txt
50


And file B.txt contains:

C.txt
27


And file C.txt contains:

10
2


Then the output of passing A.txt to the function might look something like this:

A.txt - 111
B.txt - 39
C.txt - 12
I have tried everything I can but it only shows result for the first file
Programming › Re: Thread For Nairaland Algorithm Questions by cbrass(op): 9:05pm On Sep 24, 2021
cyrielo:
I have a solution for this in JavaScript, will probably like a feedback if you’re interested
okay can I see it, though I prefer php
Programming › Re: Algorithm Test Needed by cbrass(op): 9:35pm On Sep 06, 2021
ugonna1054:
why not visit the respective websites to see the questions huh
you need to pay forsome
Culture › Re: Olu Of Warri Dissolves Council Of Chiefs by cbrass(m): 6:14pm On Sep 01, 2021
Sewgon79:
Sir you are right about Oduduwa having many children but the only FEMALE child Oduduwa have gave birth to is called "IYUNADE" which gave birth to the first King of Owu. OLOWU not OLUWO. The story of Oluwo is different. Iwo in Osun was created by son of First Female King of Ile Ife, Ooni Luwo Gbagida, who also happen to be the last Female Ooni. Who married one of her chief and give back to a son which can not lay claim to the throne and has to be sent seek "Ifa" help and went on journey to discover the town that is called Iwo Today. And he became the first King of Iwo being from Ile Ife dynasty.
I am sorry, you are not right on that of Iyunade. Do you know how old Owu is, why did you think that they used to say that Owu la koko da. She married Olowu, she didn't give birth to Olowu. Owu has been before Oduduwa was even born
Culture › Re: Olu Of Warri Dissolves Council Of Chiefs by cbrass(m): 12:28pm On Sep 01, 2021
Bigsunny01:
Sorry I know it's pain to believe, but u don't expect me to believe ur illusion grin
and what is that illusion wink
Culture › Re: Olu Of Warri Dissolves Council Of Chiefs by cbrass(m): 12:26pm On Sep 01, 2021
FMAKJ:
Lol u trying to let my cat out of the bag already.

Maybe cbrass is also the owner of this account.
i don't do that
Culture › Re: Olu Of Warri Dissolves Council Of Chiefs by cbrass(m): 8:34am On Sep 01, 2021
Bigsunny01:
And Izoduwa/Oduduwa is a banish prince from Bini

Get dat
you people have started again grin the story has changed from a young boy running in the forests of Bini to the banished prince. grin
Culture › Re: Olu Of Warri Dissolves Council Of Chiefs by cbrass(m):
FMAKJ:
Ok, Okanbi has how many children? and where did they relocated to?
If you are ready to hear undiluted truth about the Yoruba, and ready to hear what you have never heard before then head to YouTube. Search for Tani Yoruba by Laji Abbas cheesy
When I get to work i may help you look for the link to make things faster

modified
start your learning from here. it will take you days to finish it though

https://www.youtube.com/watch?v=I46wmS_dCtE&t=1s
Culture › Re: Olu Of Warri Dissolves Council Of Chiefs by cbrass(m): 7:59am On Sep 01, 2021
FMAKJ:
Im not pushing for oyo or anywhere, I am only saying things as they are and according to correct history.

Do you also know that Oranmiyan met some people in Binin called Igodomigodo. So, is not like there was nobody in Benin when he got there.
I am not talking about Bini, let's focus on the Oduduwa story you started. It is false, it was started to spite Ife. I have never seen an Ife indegine that says the okanbi story. Then when you even said that Okanbi gave birth to Ooni through a slave made me laugh. Did you know what the leader of Ife was called at that time before it became Ooni.
Culture › Re: Olu Of Warri Dissolves Council Of Chiefs by cbrass(m): 7:36am On Sep 01, 2021
FMAKJ:
I am not even from oyo. My own story is for another day which will surprise you. That oduduwa story falling from the sky is a lie. Lamurudu gave birth to Oduduwa,simple!

Now, do you know that Lamurudu met certain people in ife when he arrived?

Now, to give you a tip of where I come from, I am from that certain people lamurudu met in ife.
If you are from Ife then why are you pushing Oyo version of Oduduwa history, I am Still not surprised though because it is from Ife they push most of the lies we have in Yoruba land out even though they know the truth
Culture › Re: Olu Of Warri Dissolves Council Of Chiefs by cbrass(m): 7:13am On Sep 01, 2021
FMAKJ:
It was Okani the son of Oduduwa that has Eight children. Oranmiyan is the number 7 while Ooni is the number 8 via a slave woman and Ooni became the king after Okani passed away. Oranmiyan then went to Oyo and found Oyo.
I won't argue with you, it is the stories you hear people saying about that you accepted, and your version of Odudwa story shows you are likely to come from Oyo because they are the ones that started that version. I won't blame you though, I also believed the story of Oduduwa falling from the sky for many years
Culture › Re: Olu Of Warri Dissolves Council Of Chiefs by cbrass(m): 6:55am On Sep 01, 2021
FMAKJ:
Ok, do me a favour. Check the bronze head of the first king of warri
(Ginuwa) and compare the face with the previous king of warri.
Please don't get me wrong o. Itsekiri is 95% Yoruba. Even the Royal family that came from Bini, in fact the royal family is still a combination of Ife and bini. So you are right on that one but the story of oduduwa uou wrote is not the true one, in fact Oduduwas children are so many, he also gave birth to females too. One of them is the mother of the founder of Iwo in Osun srate
Culture › Re: Olu Of Warri Dissolves Council Of Chiefs by cbrass(m): 6:43am On Sep 01, 2021
FMAKJ:
Do you know that the first king of warri is a generational son of one of the king of Benin, while the first king of Benin is called Ewaka 1, Ewaka dad is called Oranmiyan the 7th son of Okani, while Okani is the only son of Oduduwa.

By the way, Oduduwa dad is called Lamurudu.

Now you see how Delta,warri and yorubas are related.
Hmm this your history get as e be. Not really true
Programming › Algorithm Test Needed by cbrass(op): 1:08am On Aug 27, 2021
Please if you have hackeranck or leetcode questions, kindly share.

Thanks
Business › Re: Kevin Ajenifuja: Dangote Drugged My Wife, Got Her Raped, Stole My Trade Secrets by cbrass(m): 10:05pm On Aug 18, 2021
Oluolad86:
cry Dear Lord please heal me now from pericarditis cry cry
I jsut prayed for you now.
You are healed already. Be ready to type the testimony of your healing right now.
Hold fast to Isaiah 53:5
Rejoice greatly because it is done and you will have the healing.

I will be waiting for your testimony thread tomorrow sister wink
Health › Re: How Does One Manage Partial Stroke?? by cbrass(op): 11:15pm On Aug 08, 2021
Jagabanj:
please I will really need your help
Okay, in what ay please?
Properties › Land For Sale At Ibadan by cbrass(op): 8:38pm On Aug 02, 2021
A Plot of Land for sale at Egan-Arin, Off Bako. Apata Ibadan.
Price :N600k
Contact: 07087057654
Romance › Re: Help! I Don't Feel Sexually Attracted To My Fiancée by cbrass(m): 12:27am On Jul 25, 2021
zyphr:
grin grin I'll like to know more about yours. Can we chat on telegram?
I am more active on WhatsApp than Telegram o, what do you think
Romance › Re: Help! I Don't Feel Sexually Attracted To My Fiancée by cbrass(m): 4:02pm On Jul 24, 2021
zyphr:
I have been in a relationship with my girlfriend since September 2019. I intend to marry her.
The problem is that, I don't desire her sexually. Any intimate touch from her feels like the touch from a blood sister. Very uncomfortable.
She is a strict Christian with a policy of no premarital sex. So we have never had sex except for occasional kissing and romance which I sometimes initiate.
However, since January this year, I lost sexual attraction towards her and I avoid even simple touches. In fact, last Sunday we were walking down the street and when she placed her arms round my shoulder, I stylishly evaded it. I don't feel like this towards every other woman.

I'm currently not seeing any other lady but I have had sexual flings with two different ladies including an ex.

Question is: Is sexual attraction/desire neccesary for marriage? Is it normal not to feel sexually attracted to your partner? Can this be a basis for break up as I fear it might persist in marriage and make me cheat on her.
I am experiencing something similar too at the moment ,please if you found a solution kindly let me know
Politics › Re: DSS didn't arrest me, Sunday Igboho debunks arrest rumour by cbrass(m): 10:57pm On Jul 02, 2021
what do you want to gain in spreading lies grin grin

All efforts to stop the rally for tomorrow cheesy cheesy
Programming › Re: C# Vs Java by cbrass(m): 5:32pm On Jun 17, 2021
how can C# be harder than Javascript grin...well we all have different capabilities sha
Programming › Re: Is Web Programming Now Shifting Base? by cbrass(op): 8:27pm On Jun 16, 2021
Karleb:
Bros, e be like say you don dey interview with Microsoft.

In case you need to know, I'm doing well! grin
seems you don dey learn witchcraft o cheesy cheesy
how you take know
Programming › Re: Is Web Programming Now Shifting Base? by cbrass(op): 4:02pm On Jun 16, 2021
Arkmanbuddy:
No vex jare, my blood dey hot ni! grin
i understand you grin grin grin
Programming › Re: Is Web Programming Now Shifting Base? by cbrass(op): 2:45pm On Jun 16, 2021
Arkmanbuddy:
Only the naive and valueless coders will be edged out o the industry. The experienced ones who have been in the game for sometime will always make money more than the computer science graduates you're talking about. You think it's about degree and some stupid theories that are being taught in schools, the real coders don't need interviews for jobs, they know how they make their money.
Bro calm down nw, you don dey vex ni grin
This is not a fight o, just stating the new trend now
Programming › Is Web Programming Now Shifting Base? by cbrass(op): 2:21pm On Jun 16, 2021
I could remember some 10 years ago web developers were not considered or regarded as programmers, even here on nairaland there used to be a fight between web developers and computer science students.
The fact that these web guys make more money even caused most CSE students/graduates to get angrier.
This fight is not limited toNairalnd alone, it happens on almost any forum at that time.

Now it seems the science guys may be winning now as things have changed.
Now if you didn't study computer science or Mathematics in the University you may find it difficult to cope during interview sessions and tests.

The term "Web developer" or "Coder" has been faced out gradually hence the word Software Engineer/Developer is in vogue now.

You need to be grounded now in Data structures, design patterns, algorithms, etc for you to fit in.
If you didn't study computer science while in school you may find it hard to navigate your way,
Then with the way the tech world is going so many branches are now been created eg DevOps and the likes.

Let me know what you guys think

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 (of 179 pages)