Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,150,501 members, 7,808,851 topics. Date: Thursday, 25 April 2024 at 05:56 PM

Challenge Me - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Challenge Me (15483 Views)

(2) (3) (4)

(1) (2) (3) (4) (5) (6) (7) (8) (9) (10) (Reply) (Go Down)

Challenge Me by seunthomas: 8:11am On Oct 20, 2017
While i was on my long stay in Krypton, i be hear say some small pikin dey contest with me to challenge me on coding..
Oya all of una wey no dey fear make una come out. I get time for una.
He no easy to be undisputed.
50 KO baby..........

1 Like

Re: Challenge Me by Nobody: 8:35am On Oct 20, 2017
If i try to post now, the bloo.dy moderator will block it again.
Re: Challenge Me by seunthomas: 8:38am On Oct 20, 2017
dhtml118:
If i try to post now, the bloo.dy moderator will block it again.
You to find trouble which one is blood.dy again. You don post but them no ban you.
Abeg JUMP and Pass if you are not here for Challenge...
Re: Challenge Me by Nobody: 8:44am On Oct 20, 2017
Hmn, you have a point, okay, I Tony, omo ile Ajanlekoko, hereby challenge the almighty Seun thomas to a programming contest.
Oya, state the nature of the challenge and lets get going!

1 Like

Re: Challenge Me by seunthomas: 8:46am On Oct 20, 2017
dhtml118:
Hmn, you have a point, okay, I Tony, omo ile Ajanlekoko, hereby challenge the almighty Seun thomas to a programming contest.
Oya, state the nature of the challenge and lets get going!
I am undisputed. Na you go fire the first question....
Re: Challenge Me by Nobody: 8:50am On Oct 20, 2017
Just imagine the insult. It is sustained anyway in the spirit of programming.

So that they will not say that I am cheating, let another person on the thread state the nature of the challenge.
Re: Challenge Me by bearnana(f): 9:11am On Oct 20, 2017
Just here to watch...

1 Like

Re: Challenge Me by donsheddy1(m): 10:17am On Oct 20, 2017
Build a simple algorithm that converts English to Morse code.
Re: Challenge Me by seunthomas: 10:37am On Oct 20, 2017
donsheddy1:
Build a simple algorithm that converts English to Morse code.

class Morsify:
codedict = {'A': '.-', 'B': '-...', 'C': '-.-.',
'D': '-..', 'E': '.', 'F': '..-.',
'G': '--.', 'H': '....', 'I': '..',
'J': '.---', 'K': '-.-', 'L': '.-..',
'M': '--', 'N': '-.', 'O': '---',
'P': '.--.', 'Q': '--.-', 'R': '.-.',
'S': '...', 'T': '-', 'U': '..-',
'V': '...-', 'W': '.--', 'X': '-..-',
'Y': '-.--', 'Z': '--..',

'0': '-----', '1': '.----', '2': '..---',
'3': '...--', '4': '....-', '5': '.....',
'6': '-....', '7': '--...', '8': '---..',
'9': '----.'
}
reversedict = {value:key for key,value in codedict.items()}
def __init__(self,word):
self.word=word

def translateEnglishToMorse(self):
return ' '.join(self.codedict.get(i.upper()) for i in self.word)

def translateMorseToEnglish(self,code):
return ''.join(self.reversedict.get(i) for i in code.split())

if __name__=="__main__":
word="NAIRALAND"
transcribe = Morsify(word)
morsecode= transcribe.translateEnglishToMorse()
print transcribe.translateMorseToEnglish(morsecode)

4 Likes

Re: Challenge Me by Nobody: 10:57am On Oct 20, 2017
that is a too generic something, it is something that you can get easily on google or wherever.
Re: Challenge Me by seunthomas: 11:08am On Oct 20, 2017
dhtml118:
that is a too generic something, it is something that you can get easily on google or wherever.
Exactly ohhhh. I been dey wonder why dem go post that kind question....
Re: Challenge Me by seunthomas: 11:11am On Oct 20, 2017
donsheddy1:
Build a simple algorithm that converts English to Morse code.
I have a crate of 20 eggs, 5 of the eggs are bad, i want to arrange them in such a way that the bad eggs are together all seperated from the good ones. Create a class in any language of your choice that would take 2 parameters (List containing all the eggs and a List of the bad eggs) and arrange them so the bad eggs are always sorted last.

2 Likes

Re: Challenge Me by Nobody: 12:12pm On Oct 20, 2017
Excellent:

Let us put it like this:

Good eggs:
e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20

Bad eggs:
e3, e7, e11, e17, e19

I will tackle this with plain javascript, and then php
Re: Challenge Me by bearnana(f): 12:56pm On Oct 20, 2017
With PHP

<?php

function get_good_eggs( $all_eggs, $bad_eggs) {

$bad_eggs = array_intersect($all_eggs,$bad_eggs);
$good_eggs = array_diff($all_eggs,$bad_eggs);
foreach($bad_eggs as $key => $value) {
$good_eggs[] = $value;
}
return $good_eggs;
}

?>

Apologies for my shrewd variable names

4 Likes

Re: Challenge Me by Nobody: 1:27pm On Oct 20, 2017
bearnana, you failed the test : here is the correct php answer

class Igbo {

public static function get_good_eggs( $all_eggs, $bad_eggs) {

$bad_eggs = array_intersect($all_eggs,$bad_eggs);
$good_eggs = array_diff($all_eggs,$bad_eggs);
foreach($bad_eggs as $key => $value) {
$good_eggs[] = $value;
}
return $good_eggs;
}

public static function all_eggs($all,$bad) {
$response=self::get_good_eggs($all,$bad);
var_dump($bad);
var_dump($response);
}

}


Test code:
$all_eggs=['e1', 'e2', 'e3', 'e4', 'e5', 'e6', 'e7', 'e8', 'e9', 'e10', 'e11', 'e12', 'e13', 'e14', 'e15', 'e16', 'e17', 'e18', 'e19', 'e20'];
$bad_eggs=['e3', 'e7', 'e11', 'e17', 'e19'];

Igbo::all_eggs($all_eggs,$bad_eggs);


Result:
/www/test.php:16:
array (size=5)
0 => string 'e3' (length=2)
1 => string 'e7' (length=2)
2 => string 'e11' (length=3)
3 => string 'e17' (length=3)
4 => string 'e19' (length=3)
/www/test.php:17:
array (size=20)
0 => string 'e1' (length=2)
1 => string 'e2' (length=2)
3 => string 'e4' (length=2)
4 => string 'e5' (length=2)
5 => string 'e6' (length=2)
7 => string 'e8' (length=2)
8 => string 'e9' (length=2)
9 => string 'e10' (length=3)
11 => string 'e12' (length=3)
12 => string 'e13' (length=3)
13 => string 'e14' (length=3)
14 => string 'e15' (length=3)
15 => string 'e16' (length=3)
17 => string 'e18' (length=3)
19 => string 'e20' (length=3)
20 => string 'e3' (length=2)
21 => string 'e7' (length=2)
22 => string 'e11' (length=3)
23 => string 'e17' (length=3)
24 => string 'e19' (length=3)
Re: Challenge Me by talk2hb1(m): 3:09pm On Oct 20, 2017
I challenge you to building a Machine Learning Library/Solution just like Google machine that detect unusual users login undecided
Re: Challenge Me by greatface(m): 3:21pm On Oct 20, 2017
Just Here To Learn
Re: Challenge Me by bolkay47(m): 3:21pm On Oct 20, 2017
Euler's Totient function, φ(n) [sometimes called the phi function], is used to determine the number of positive numbers less than or equal to n
which are relatively prime to n. For example, as 1, 2, 4, 5, 7, and 8, are all less than nine and relatively prime to nine, φ(9)=6.
The number 1 is considered to be relatively prime to every positive number, so φ(1)=1.
Interestingly, φ(87109)=79180, and it can be seen that 87109 is a permutation of 79180.
Find the value of n, 1 n 107, for which φ(n) is a permutation of n and the ratio n/φ(n) produces a minimum.

1 Like

Re: Challenge Me by seunthomas: 3:56pm On Oct 20, 2017
talk2hb1:
I challenge you to building a Machine Learning Library/Solution just like Google machine that detect unusual users login undecided
Though i have experience in ML, doing this is not a small task. For a real good system it would cost a lot of money and data. This days i use mostly deep learning because in most cases its better than other approaches to AI. If you can foot my bill, i can accept your challenge for at least 2-5 million NGN.
Re: Challenge Me by seunthomas: 3:57pm On Oct 20, 2017
bolkay47:
Euler's Totient function, φ(n) [sometimes called the phi function], is used to determine the number of positive numbers less than or equal to n
which are relatively prime to n. For example, as 1, 2, 4, 5, 7, and 8, are all less than nine and relatively prime to nine, φ(9)=6.
The number 1 is considered to be relatively prime to every positive number, so φ(1)=1.
Interestingly, φ(87109)=79180, and it can be seen that 87109 is a permutation of 79180.
Find the value of n, 1 n 107, for which φ(n) is a permutation of n and the ratio n/φ(n) produces a minimum.
Do i take it you are challenging me?
Re: Challenge Me by bearnana(f): 4:46pm On Oct 20, 2017
dhtml118:
bearnana, you failed the test : here is the correct php answer


I know how to write classes in PHP, why don't you give me credit that my function works

bolkay47:
Euler's Totient function, φ(n) [sometimes called the phi function], is used to determine the number of positive numbers less than or equal to n
which are relatively prime to n. For example, as 1, 2, 4, 5, 7, and 8, are all less than nine and relatively prime to nine, φ(9)=6.
The number 1 is considered to be relatively prime to every positive number, so φ(1)=1.
Interestingly, φ(87109)=79180, and it can be seen that 87109 is a permutation of 79180.
Find the value of n, 1 n 107, for which φ(n) is a permutation of n and the ratio n/φ(n) produces a minimum.


This is interesting...
Re: Challenge Me by talk2hb1(m): 4:49pm On Oct 20, 2017
seunthomas:

Though i have experience in ML, doing this is not a small task. For a real good system it would cost a lot of money and data. This days i use mostly deep learning because in most cases its better than other approaches to AI. If you can foot my bill, i can accept your challenge for at least 2-5 million NGN.

Gbese!!!!
Re: Challenge Me by Nobody: 4:50pm On Oct 20, 2017
bearnana:


I know how to write classes in PHP, why don't you give me credit that my function works



This is interesting...

Adon thief the credit ni o. You really tried, seriously, weldone sir.
Re: Challenge Me by Nobody: 4:51pm On Oct 20, 2017
talk2hb1:

Gbese!!!!
Pay me 200k to attempt, and 300k more if I pass.
Re: Challenge Me by bearnana(f): 5:22pm On Oct 20, 2017
bolkay47:
Euler's Totient function, φ(n) [sometimes called the phi function], is used to determine the number of positive numbers less than or equal to n
which are relatively prime to n. For example, as 1, 2, 4, 5, 7, and 8, are all less than nine and relatively prime to nine, φ(9)=6.
The number 1 is considered to be relatively prime to every positive number, so φ(1)=1.
Interestingly, φ(87109)=79180, and it can be seen that 87109 is a permutation of 79180.
Find the value of n, 1 n 107, for which φ(n) is a permutation of n and the ratio n/φ(n) produces a minimum.

Is anybody working on this?? Any headway yet?
Re: Challenge Me by talk2hb1(m): 5:50pm On Oct 20, 2017
dhtml118:

Pay me 200k to attempt, and 300k more if I pass.
Cant someone not play with all of una in pease again
undecided
Re: Challenge Me by talk2hb1(m): 5:57pm On Oct 20, 2017
talk2hb1:
I challenge you to building a Machine Learning Library/Solution just like Google machine that detect unusual users login undecided
I am trying write a Tutorial on this, but kinda,buzy. This is a scaled down version, so
I am using bayes conditional probability model to predict patterns.
Re: Challenge Me by bearnana(f): 6:39pm On Oct 20, 2017
With PHP

<?php
function generate_primes($n) {
$limit = sqrt($n);
$primes = array_fill(0, $n, 0);
$primes[0] = $primes[1] = 1;
for($i = 2; $i <= $limit; $i++) {
if($primes[$i] === 0) {
for($j = 2; $j < $n; $j++) {
if($i*$j > $n)
break;
else
$primes[$i*$j] = 1;
}
}
}
return sizeof($primes)-1;
}


?>

I just noticed that this is incomplete, it only solves the Euler Totient function... I'll update later...
bolkay47:
Euler's Totient function, φ(n) [sometimes called the phi function], is used to determine the number of positive numbers less than or equal to n
which are relatively prime to n. For example, as 1, 2, 4, 5, 7, and 8, are all less than nine and relatively prime to nine, φ(9)=6.
The number 1 is considered to be relatively prime to every positive number, so φ(1)=1.
Interestingly, φ(87109)=79180, and it can be seen that 87109 is a permutation of 79180.
Find the value of n, 1 n 107, for which φ(n) is a permutation of n and the ratio n/φ(n) produces a minimum.
Re: Challenge Me by bolkay47(m): 6:36am On Oct 21, 2017
bearnana:
With PHP

<?php
function generate_primes($n) {
$limit = sqrt($n);
$primes = array_fill(0, $n, 0);
$primes[0] = $primes[1] = 1;
for($i = 2; $i <= $limit; $i++) {
if($primes[$i] === 0) {
for($j = 2; $j < $n; $j++) {
if($i*$j > $n)
break;
else
$primes[$i*$j] = 1;
}
}
}
return sizeof($primes)-1;
}


?>

I just noticed that this is incomplete, it only solves the Euler Totient function... I'll update later...
Nice!

1 Like

Re: Challenge Me by DharkPoet(m): 11:15am On Oct 22, 2017
bolkay47:
Euler's Totient function, φ(n) [sometimes called the phi function], is used to determine the number of positive numbers less than or equal to n
which are relatively prime to n. For example, as 1, 2, 4, 5, 7, and 8, are all less than nine and relatively prime to nine, φ(9)=6.
The number 1 is considered to be relatively prime to every positive number, so φ(1)=1.
Interestingly, φ(87109)=79180, and it can be seen that 87109 is a permutation of 79180.
Find the value of n, 1 n 107, for which φ(n) is a permutation of n and the ratio n/φ(n) produces a minimum.

Here you go @bolkay47 done in PHP


<?php
// Find the GCD between two numbers
function getGCD($num1, $num2) {
while ($num2 != 0){
$t = $num1 % $num2;
$num1 = $num2;
$num2 = $t;
}
return $num1;
}

function PHIfunction($n) {
if ($n == 1) {
return 1;
}
$count = 0;
for ($i=1; $i < $n; $i++) {
if (getGCD($i, $n) === 1) {
$count++;
}
}
return $count;
}

echo PHIfunction(9);
// returns 6

echo PHIfunction(20);
// returns 8

echo PHIfunction(87109)
// returns 79180

?>

1 Like

Re: Challenge Me by Nobody: 11:18am On Oct 22, 2017
See them bad guys, I no even fit read these codes, they be like magic to me (maybe I need e-glasses as old e-age don set in).
Re: Challenge Me by DharkPoet(m): 11:24am On Oct 22, 2017
dhtml118:
See them bad guys, I no even fit read these codes, they be like magic to me (maybe I need e-glasses as old e-age don set in).
That's how you will be yabbing somebody grin grin

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

Are Mini Laptops Good For Programming? / Why Self Taught Programmers Over “Exaggerate”. / Is It Advisable To Learn Java As My First Programming Language?

(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. 67
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.