Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,154,734 members, 7,824,073 topics. Date: Friday, 10 May 2024 at 09:58 PM

Jacob05's Posts

Nairaland Forum / Jacob05's Profile / Jacob05's Posts

(1) (2) (3) (4) (5) (6) (7) (8) (9) (10) (of 37 pages)

Business / Re: ➜ ➜ ➜Currency/E-currency Market Deals➜ ➜ ➜ by jacob05(m): 7:18pm On Jan 10, 2017
bdavis:
Ok, so...today being a very special day...took my first breathe on this very day exactly 2 score years ago...

In appreciation to being alive and thanking God for such a wonderful and marvelous journey so far, I have decided to drop $30 to a sharp nairalander...

But cos na me, the person go proof say hin sharp.

So here goes:


Decode this:

LZVA73AZQ5LTMVU


tell us what it is, the value associated with it, and get $30

NB: you have to tell us how you arrived at the value.
Birthday Gift Card Code?
Business / Re: ➜ ➜ ➜Currency/E-currency Market Deals➜ ➜ ➜ by jacob05(m): 6:10pm On Dec 16, 2016
Big-ups to @bdavis for the awesome transaction. bdavis helped out with the ordering of my Monitor with Gift card on Amazon.

Highly recommending bdavis.

Business / Re: ➜ ➜ ➜Currency/E-currency Market Deals➜ ➜ ➜ by jacob05(m): 8:33pm On Dec 07, 2016
I need $581 worth of amazon gift card.

Kindly reach out on 0,8,1, 63949712. Thanks
Programming / Re: Jquery Plugin For Nigeria States And Corresponding Lga by jacob05(m): 9:23pm On Sep 04, 2016
dhtml18:
@guru, you actually wrote something very nice this time. I however was not too pleased with the syntaxes, so i forked the code to - https://github.com/dhtml/jquerynigeriastatelga

Now this version is somewhat simpler for me to use, i cant say for others.

Baba, send PR to the main repo. grin grin
Programming / Re: Php Micro Framework by jacob05(m): 10:13pm On Aug 07, 2016

1 Like

Programming / Re: Laravel Issue by jacob05(m): 4:12pm On Jul 18, 2016
1). Are you sure you're amending the currently used php.ini file use the below to check
>php --ini

2). Is the Uwamp server compiled with the Openssl included?
Programming / Re: Andela Will Empower Africa's Next Generation Of Great Technical Leaders by jacob05(m): 5:24pm On Jun 21, 2016
Nmeri17:
you wan gather your guys dem come obtain me?? grin Abeg! I work in the Lord's vineyard smiley Awon permanent secretary cool Team no leave, no transfer. And my last post on this thread was meant to be funny; I'm sorry if you feel butthurt. Your Darling Andela does not rear weaklings. sad

grin grin grin
butthurt Naaa... any reason to be
I asked because I'm curious to know the standard of the place you work for you to say such. ¯\_(ツ)_/¯
Programming / Re: Andela Will Empower Africa's Next Generation Of Great Technical Leaders by jacob05(m): 10:47am On Jun 21, 2016
dhtml18:

Ahem, Jamb Question!

Programming / Re: Andela Will Empower Africa's Next Generation Of Great Technical Leaders by jacob05(m): 9:49am On Jun 21, 2016
Nmeri17:
^^^ Why won't you tire weakling! angry Andela rears weaklings!! angry angry



Where do you work pls?
Programming / Re: Andela Will Empower Africa's Next Generation Of Great Technical Leaders by jacob05(m): 4:28pm On Jun 19, 2016
Passing by.

mrdcai: You seem to know a lot.

Programming / Re: Phpsocket.io-Real-time Chat Engine With HTML & Android Client Support [Updated] by jacob05(m): 5:45pm On Jun 01, 2016
dhtml18:

True
@guru01, i have developed this library over a year ago. But i am just publishing it for public consumption for the first time - so should I call it version 5.0? because there has been many revisions since the first time I made it.
There is an a chat android application that is rather similar to whatsapp that i developed 2 years back, it runs on this platform. Nairaland developers that are very close to me have already seen this in action - and some of them already had the source code of the library even as far back as last year.
All i did not was to standardize the codes a bit and publish it. If you check the github link very well - https://github.com/dhtml/phpsocket.io - you will find out that it has been published on github like 6 months ago.
Any plans towards refactoring the code, writing tests and breaking the classes into files?
Programming / Re: Simple Factorial Challenge by jacob05(m): 11:25am On Jun 01, 2016
xrange would be better though... performance wise. wink ... But It won't kill for now.. grin grin grin
Programming / Re: Simple Factorial Challenge by jacob05(m): 11:23am On Jun 01, 2016
slysoft:
@jacob05

Impressive script, i just learned something.

The loop in your script started from 2 till 5001... can you explain why?

x^2 + (5/3)x^3 + (23/12)x^4 + (119/60)x^5 ... + (2*[5000!-1]/[5000!])x^5000

The power starts from 2 to 5000... range( 2, 5001 ) generates a sequence from 2 to 5001 - 1 (5000).. wink
Programming / Re: Simple Factorial Challenge by jacob05(m): 5:07am On Jun 01, 2016
slysoft:



Hi @jacob05,

I designed the php script @slyrox uploaded for the problem... as @Lyphiard rightly mentioned that the problem @OP posted came from a competition in USA which we solved in our team before sharing it nairaland to develop other programmers on this platform.

The accepted solution/result on the competition portal was "5.08845978368001251890" which is the same as the result of our script/algorithm and different from the solution/result of your script/algorithm "5.088459783680012467179075225".

However, this is how we solved it or how we got the algorithm;

1
Looking at the equation posted;
x^2 + (5/3)x^3 + (23/12)x^4 + (119/60)x^5 ... + (2*[5000!-1]/[5000!])x^5000
it can easily be translated into a summation equation
which is to sum the result of ((2 * ([a+1]! – 1) / [a+1]! ) * x^(a+1) from a = 1 till 5000 where x is a constant
so for a = 1 we have x^2
a = 2 we have (5/3)x^3
sum the results till a = 5000


All we did was to translate the deduced summation equation into a script/algorithm. there was no reason behind using php, I could have used several other lang java, C#, VB, C, ruby, python

The result of the problem was also requested in the nearest 20 decimal places. why i added bcscale(25) is to control the number of trailing digits after the decimal and not affect the integrity of the 20th digit after the decimal. then i took off the trailing 5 digits after the 20th decimal

2: I will be willing to learn if you comeup with a much quicker or less-lame solution with regards to the posted problem. Thanks smiley


BTW, My understanding of your script is that 35000 = 5000!; correct me if i am wrong.


And that is still naive and the wrong way of solving the problem (Although it gives you the correct answer ). The organizers of code competitions knows the easy, and mostly expensive, way of solving the problem and they most times set that trap for you. (Learnt the Hard way in the Google Code Jam 2016).
Always avoid factorial loops that move towards 1000 ... It's a trap !!!... Finding factorial is an expensive runtime operation.(Especially one that tends towards 1000) Quote me if I'm wrong.

2:

from decimal import *
import math

x = Decimal('0.7893')

beginH = Decimal('1.0' )
beginB = Decimal('1.0' )

multi = Decimal('3' )
adder = Decimal('2' )

r = Decimal('0.0')
for i in range( 2, 5001 ) :
r = r + ( ( beginH/beginB ) * Decimal( x ** i ) )

beginH = multi * beginH + adder
beginB = multi * beginB
multi +=1
adder +=1
print '{0:.21g}'.format(r)

Funny enough, It's relatively the same script I posted!!!. The issue with previous was with my use of float for x.. (floats are mostly not accurate)
and this
beginH = Decimal(1.0).

The issue with the above is that 1.0 is a floating point value .. which is not exactly 1.0 when converted into decimal...(don't blame me.. tongue tongue grin grin ). Just had to put single quotes... beginH = Decimal('1.0')... Did the same for the rest... lobatan... grin

3. Yes but I did not use the expensive factorial method to calculate the result. smiley
Programming / Re: I Want To Learn Programming. Which Language Should I Start With? by jacob05(m): 11:50am On May 28, 2016
Python... !!!
Programming / Re: Simple Factorial Challenge by jacob05(m): 7:19pm On May 27, 2016
olyjosh:


I begin to love dis python of a thing oo.
Your solution is quite brilliant n fast but your answer only converges upto d 15th decimal values. Unnecessary rounding in d system I guess.
Hmmm. Thanks
Programming / Re: Simple Factorial Challenge by jacob05(m): 7:20am On May 27, 2016
dozies1:
Ok.
What is the principle behind making it go faster.
Don't use factorial.. Simple
Programming / Re: Programming Interview Test by jacob05(m): 9:03pm On May 26, 2016
crotonite:
cheesy grin cheesy guyz, i finaly got it 100% cool cool

here is my code...

class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
if(A == null || A.length <= 0 || A.length > 100000)
return -1;
long r = 0;

for(int i : A)
r += i;

long l = 0;

for(int p = 0; p < A.length; p++){
r -= A[p];
if( r == l)
return p;

l += A[p] ;
}
return -1;
}
}


thanks @febup for this challenge.
Nice.

In Python


def solution(data ) :
if not type(data ) is list or len(data ) <= 0: return -1
lSum = 0; r = sum(data )
for p in xrange(0, len( data ) ) :
r -= data[p]
if (r == lSum ) : return p
lSum += data[p]
return -1
Programming / Re: Simple Factorial Challenge by jacob05(m): 6:07pm On May 26, 2016
dozies1:

here is my solution:
. 
from math import factorial
from decimal import Decimal

n = 5000
x = Decimal('0.7893')
y = Decimal('0')

for i in range(1, n+1):
y = y + 2 * (x**i) * (factorial(i)-1) / factorial(i)
print y

Please, would you mind telling me why mine is much more slower than yours.
Because you're finding and summing the factorial of numbers from 1 to 5000 : which is quite computation intensive.
Programming / Re: Programming Interview Test by jacob05(m): 10:43am On May 26, 2016
Febup:


Tried you code works fine but does not allow for P == 0 or P == N-1 as mentioned in the instruction:
Sum of zero elements is assumed to be equal to 0. This can happen if P = 0 or if P = N−1.

It's just an implementation of crotonite's solution in Python ... not entirely mine... undecided undecided
Programming / Re: Help Recommend Good Php Books by jacob05(m): 10:40am On May 26, 2016
mbatuku2:
Can someone recommend good php books for a beginner, especially written by someone in the academics? I'm open to any good author in the field that teach clearly too.
academics hmm.. not sure of that...
But you can checkout
Programming PHP 3rd Edition

[url=http://www.amazon.com/Modern-PHP-Features-Good-Practices/dp/1491905018/ref=pd_sim_14_2?ie=UTF8&dpID=51fIuBswbgL&dpSrc=sims&preST=_AC_UL160_SR122%2C160_&refRID=1SZDDA5TG0X2EHRNACKX]Modern PHP: New Features and Good Practices[/url]

PHP Advanced and Object-Oriented Programming: Visual QuickPro Guide (3rd Edition)

You can also try
[url=http://www.amazon.com/Objects-Patterns-Practice-Matt-Zandstra/dp/1430260319/ref=pd_sim_14_4?ie=UTF8&dpID=51OQucxkv%2BL&dpSrc=sims&preST=_AC_UL160_SR130%2C160_&refRID=1WAMQ9TRFXHM11Z8SDHK] PHP Objects, Patterns, and Practice 4th ed. 2013 Edition
[/url]

PHP and MySQL Web Development (4th Edition)
Programming / Re: Programming Interview Test by jacob05(m): 10:16am On May 26, 2016
Febup:


I need someone to run your code for us. Over to you dhtml18 if you have some time to spare.

use .. Repl.it - Python 2
Programming / Re: Programming Interview Test by jacob05(m): 9:57am On May 26, 2016
jacob05:

In Python

def solution(data):
lSum = 0; ret = []; rSum = sum(data )
if (rSum - data[0] == 0 ) : ret.append(1 )
lSum = data[0]
for p in xrange(1, len( data ) ) :
if (lSum == (rSum - (data[p] + lSum)) ) : ret.append(p)
lSum += data[p]
return ret
ar = [-1, 3, -4, 5, 1, -6, 2, 1 ]
result = solution(ar )
print result
Febup:
^^^
I don't have PHP setup on my machine so I tried your code on their site but it gave the error message below:

PHP Parse error: syntax error, unexpected '=' in func.php on line 6
Parse error: syntax error, unexpected '=' in func.php on line 6
RUNTIME ERROR (tested program terminated unexpectedly)

Detected some errors.

/* Your code*/
function solution($A) {
// write your code in PHP5.5
lSum = 0;
ret = [];
rSum = sum(A) )
if (rSum - A[0] == 0 ) : ret.append(1 )
lSum = A[0]
for p in xrange(1, len( A ) ) :
if (lSum == (rSum - (A[p] + lSum)) ) : ret.append(p)
lSum += A[p]
return ret
}

Attention to details ... It's in Python 2
Programming / Re: Programming Interview Test by jacob05(m): 11:46pm On May 25, 2016
crotonite:
febup here is my solution.
i implemented the function solution(...) to return an int array of p's. plz check it out!

In Python


def solution(data):
lSum = 0; ret = []; rSum = sum(data )
if (rSum - data[0] == 0 ) : ret.append(1 )
lSum = data[0]
for p in xrange(1, len( data ) ) :
if (lSum == (rSum - (data[p] + lSum)) ) : ret.append(p)
lSum += data[p]
return ret

ar = [-1, 3, -4, 5, 1, -6, 2, 1 ]
result = solution(ar )
print result
Programming / Re: Programming Interview Test by jacob05(m): 11:51am On May 25, 2016
I guess they grow "linearly" the same way.. so the solution might be valid.
Programming / Re: Programming Interview Test by jacob05(m): 11:46am On May 25, 2016
crotonite:
the prototype of my recent solution:


 import java.util.*;

public class Main
{
public static void main(String[] args)
{
//int[] data = {-1, 3, -4, 5, 1, -6, 2, 1};

int[] data = new int[100000];
Random rand = new Random();

for(int i = 0; i < data.length; i++){
data[i] = rand.nextInt();
//System.out.println(data[i]);
}

System.out.println("please wait..."wink;
double start = System.currentTimeMillis();
int equill = solution(data, data.length);

System.out.println();

System.out.println("equillibrum at : " + equill);


double stop = System.currentTimeMillis();

System.out.println("it took " + ((stop - start)/1000) + "seconds to run " );
}





private static int solution(int[] data, int n)
{
long lSum = 0, rSum = 0; //left and right summ of array
int p = 0; //index of suspected equillibrum of array

int ret = -1;

//sum array
for (int i : data)
rSum += i;


//System.out.println("sum.." + rSum);


//if first element is an aquillibrum, add to array
if (rSum - data[p] == 0)
{

return p; }

lSum = data[0];

for (int i = 0; i < n - 1; i++)
{
p++;

//System.out.println("rsum: " + rSum + " lsum: " + lSum);

rSum -= (data[p] + lSum);

if (lSum == rSum)
{

return p;

}//endif

//increment leftsum
lSum += data[p];
}


return ret;
}
}

Is the function solution not running at O(2n) cc dhtml18 Febup.
Programming / Re: Programming Interview Test by jacob05(m): 3:51pm On May 24, 2016
larisoft:



This runs in O(n).

public static int solution2(int[] nums, int n){

int sum = sum(nums);

int i = 0;
int left_sum = 0;

while(i < nums.length){

int right_sum = sum - left_sum - nums[i];

if(right_sum == left_sum){
return i;
}

left_sum+= nums[i];
i++;

}

return -1;

}

private static int sum(int[] arr){

int a = 0;
for(int i: arr){
a+=i;
}
return a;
}
Can someone explain how this runs in O(n)
cc Febup
Programming / Re: Can I Learn Python On My Own? Even With No Previous Knowledge In Programming by jacob05(m): 4:10pm On May 23, 2016
eNelo:
Sweetie, you can do learn anything on your own if you're ready to sweat. Grit is the only requirement thats indispensable to learn any technology.

The first few months of programming are usually quite tricky, but the key is this: keep coding. Books are great yes, but you could read 10 great books and not be able to compete with a coder that has doled out 10 projects.

My advice to you would be this: identify something small that you need, and create the app. Let me explain: when I first started, I noticed how much I used the Windows Sticky Notes, but I always had to write the dates myself. So I used Java to create another version of sticky notes.
It can get really confusing: not really understanding what youre doing. But it gets better pretty fast.

Also, finishing one project is no excuse to sit back. As youre finishing one, start another. Making projects is the fastest and most thoroug route to coding well IMO.

2 Likes

Programming / Re: Simple Factorial Challenge by jacob05(m): 3:25pm On May 23, 2016
cc: Yemoll
Slyr0x:
^^I will check that in a bit.

Updated


Lol, Jacob05 , you've got the wrong answer. I ran your code, saw the first 5.088459******* and then assumed you got it right.

I think your solution or your friend's isn't quite it...

Firstly, using a factorial finding function to solve this problem is wrong and naive. e.g I believe $yyy increases linearly with loop and its factorial gets calculated as the $ii increase to 5000.. try finding the factorial of 5000.. without //bcscale(25);

Lastly, bcscale(25) ; , makes the solution very likely to be inaccurate as the result of all bc functions are trimmed or scaled to 25. wink

I'm not saying mine is correct or is not tongue ... grin grin grin ... You judge... I'm just making my point.. cool
Programming / Re: Simple Factorial Challenge by jacob05(m): 11:56am On May 23, 2016
Slyr0x:
Great job Jacob05. Your solution is more efficient.

Solution below as solved by someone on my team

bcscale(25);
$itotal = "0";
$xt = "0.7893";$ii = 1;
$yyy = "1";while ($ii <= 5000)
{
$y2 = intval(gmp_add($yyy,"1"wink);
$y3 = strval($y2);

$factit = gmp_fact($y2);

$at = bcdiv(gmp_mul("2", gmp_sub($factit,"1"wink), $factit);
$xtpow = bcpow($xt,$y2);

$anst = bcmul($at,$xtpow);

$itotal = bcadd($itotal,$anst);
$yyy = gmp_add($yyy,"1"wink;
$ii++;

}

echo "Solution: " .$itotal."<br />";

Thanks
Programming / Re: Simple Factorial Challenge by jacob05(m): 8:03am On May 23, 2016
olyjosh:
Please guys, do submit your computation time and memory usage for these solutions. Anybody could have solve it, but let's see how effective is your solution in term of space and time.
You can log ur codes here https://ideone.com/ or on your machine(please do state the machine processor and memory configuration).
Thanks

https://ideone.com/DSusUY
Programming / Re: Simple Factorial Challenge by jacob05(m): 4:34pm On May 20, 2016
Slyr0x:


Calm your tits.

I solved the challenges before posting here, and the answer for this is 5.08xxxxxxxxxxxxxxxxxx.

I will release the write up later smiley.

Cheers Kiddo,

R.

Guess my solution is correct then. cool

(1) (2) (3) (4) (5) (6) (7) (8) (9) (10) (of 37 pages)

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 59
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.