₦airaland Forum

Welcome, Guest: Join Nairaland / LOGIN! / Trending / Recent / New
Stats: 2,253,050 members, 4,934,024 topics. Date: Monday, 20 May 2019 at 04:22 PM

Coding Ask And Answer (CAA) - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Coding Ask And Answer (CAA) (1507 Views)

Things you need to know as an upcoming programmer and MY CODING DAIRY / Coding Challenge For Fun / (revealed) So Mark Zuckerberg Is Not That Good At Coding/programming! (2) (3) (4)

(1) (2) (3) (4) (Reply) (Go Down)

Coding Ask And Answer (CAA) by progeek37: 12:00pm On Apr 29
Coding Ask and Answer CAA


I have created a WhatsApp group for this thread, you can drop your number here and I will add you to the group.

As the world has moved to digital era, where artificial intelligence can take control of the affairs of the world. There is a need to train
programmers who will be the driving forces. Nigerians should not be left behind in this matter, we need experienced programmers who can
bring innovations to our country.
Some people keep asking how do I learn programming and what is the best programming language to start with. I have a simple answer to this question:
Start by learning the fundamentals of programming itself and how algorithms work. The programming language to use is really irrelevant at the
moment, and no programming language is better than the others, every programming language was developed to meet urgent needs and was created for a particular purpose. So stop wasting your time jumping from one search engine to another to find out the best and lucrative programmming language. I repeat, you
can start from any programming language. You must be determined if you really want to learn programming, don't give up easily. If you have a
tendency to give up at a slight encounter of difficult syntax then I would rather recommend a programming language that has simpler approach to syntax, such
languages include Python, Java, C#, Ruby and Javascript. Starting with C or C++ may discourage some who are new to programming because of C strong use of syntax, to be able to solve a simple problem in C, you need to write many lines of code and follow many rules, the beginners who are not determined to learn programming may easily be discouraged. However, if you are determined, not even C can deter you from learning coding.
Resist the temptation to start programming by developing websites and mobile apps, you can never be successful. If you start programming like that, you will end up being a laughing stock in a software company. I repeat, don't start programming with website and app development, those things are not bad but you need to start them when you have understood how algorithms work. What is algorithm?

A sequence of steps to achieve, complete some work or obtain some result is
called an algorithm. This is how programming is related to algorithms.
Programming involves describing what you want the computer to do by a
sequence of steps, by algorithms.


Some of your colleagues directly begin programming with Web or mobile
applications and databases without knowing what an array, a list or hash
table is. Do not envy them! They have set out to do it the hard way,
backwards. They will learn to make low-quality websites with PHP and MySQL,
but they will find it infinitely difficult to become real professionals. You,
too, will learn web technologies and databases, but before you take them up,
learn how to program! This is much more important. Learning one technology or another is very easy once you know the basics, when you can
think algorithmically and you know how to tackle programming problems.

Starting to program with web applications or/and databases
is just as incorrect as studying up a foreign language from
some classical novel rather than from the alphabet and a
textbook for beginners. It is not impossible, but if you lack
the basics, it is much more difficult. It is highly-probable that
you would end up lacking vital fundamental knowledge and
being the laughing-stock of your colleagues/peers


What is the purpose of creating this thread Coding Ask and Answer? Here is a place to learn programming by solving programming problems.
Anyone can ask a question and answer a question whether you a beginner, intermidiate or an expert in programming, you can bring your knowledge to the platform. Note: this is not a thread to teach any programming language, rather it is a thread where those who are into programming can help each. What do you need to participate in the thread? You need nothing but your textbooks and text editor or any IDE of your choice. If you encounter any difficult question from the book you are reading, you can bring it up to the thread for the solution in any language.

Reading books without practicing is meaningless! You
must spend much more time on writing programs than
reading the text itself. It is just like learning to drive: no one
can learn driving by reading books. To learn driving, you
need to drive many times in different situations, roads, cars,
etc. To learn programming, you need to program!
Everybody has studied maths in school and knows that learning how to solve
maths problems requires lots of practice. No matter how much they watch and
listen to their teachers, without actually sitting down and solving
problems, they won’t learn. The same goes for programming. You need
lots of practice. You need to write a lot, to solve problems, to experiment, to
endeavor in and to struggle with problems, to make mistakes and correct
them, to try and fail, to try anew and experience the moments when things
finally work out. You need lots and lots of practice. This is the only way you
will make progress. So people say that to become a developer you might need to write at least
50,000 – 100,000 lines of code, but the correct number can vary a lot. Some
people are fast learners or just have problem-solving experience. Others may
need more practice, but in all cases practicing programming is very
important! You need to solve problems and to write code to become a
developer. There is no other way!


I have created a WhatsApp group for this thread, you can drop your number here and I will add you to the group.
Re: Coding Ask And Answer (CAA) by horlahwaley(m): 12:27pm On Apr 29
08062606144
Re: Coding Ask And Answer (CAA) by progeek37: 12:35pm On Apr 29
horlahwaley:
08062606144
Okay. Welcome to the world of programmers. Luckily you are one of the forerunners of this great vision as you are one of the first people to join.

1 Like

Re: Coding Ask And Answer (CAA) by progeek37: 1:06pm On Apr 29
Here is a sample question

In Nigeria, mobile phone numbers begin with the digit 0 and can contain any digits(0,1,2,3,4,5,6,7,8,9). The first 4 digits of the numbers
determine the particular network provider. For instance, GlobalCom Nigeria Limited numbers can
begin with 0805, MTN 0803 and Airtel 0802 etc. The mobile phone numbers must
have 11 digits all together. For instance, this is my MTN number:
0813 568 3431.
Write a program that can calculate the total number of possible subscribers of
MTN numbers that begin with 0813 and print out all the numbers.


HINT
total_digits = 11: total digits of each number
digits_needed = 7: digits needed to complete 0813 to 11-digit numbers.
available_digits = 10: i.e 0,1,2,3,4,5,6,7,8,9
Note: Computer CPU has some limitations, some may not print out all the numbers. Instead of printing out all the numbers in computers with low
processor speed and RAM. Consider printing out numbers that meet some certain conditions like numbers that ends with "3431" like my number
in the question. But your program must be able to count all the total available numbers in "0813" even though it may not print them all out to the console.
Also you have to make the program flexible such that you can easily change the lines for instance, you change can "0813" to "0806", "0803", "0805", "0902" etc or even make it start with country code "+234813". Goodluck.
Re: Coding Ask And Answer (CAA) by airsaylongcon: 1:11pm On Apr 29
Does the total number of possible subscribers change if its 0803 or 0902? undecided
Re: Coding Ask And Answer (CAA) by hitan(m): 2:56pm On Apr 29
07061836156
Re: Coding Ask And Answer (CAA) by progeek37: 4:49pm On Apr 29
airsaylongcon:
Does the total number of possible subscribers change if its 0803 or 0902? undecided
No! The total number of possible subscribers remains the same..."0803", "0813" etc are just prefixes.
Note: The prefix just makes the numbers in it different from the numbers in other prefixes.
As we know when the number of subscribers reaches the total, the network providers will respond by introducing another prefix.
Re: Coding Ask And Answer (CAA) by airsaylongcon: 5:20pm On Apr 29
progeek37:

No! The total number of possible subscribers remains the same..."0803", "0813" etc are just prefixes.
Note: The prefix just makes the numbers in it different from the numbers in other prefixes.
As we know when the number of subscribers reaches the total, the network providers will respond by introducing another prefix.

Exactly why I asked. I love your question though. Very brain scratching although I'm sure I can solve it if I get to it. I'd just be lazy and get it done with excel.

Is 0813 000 0000 a valid number though? How about 0813 999 9999?
Re: Coding Ask And Answer (CAA) by progeek37: 8:10pm On Apr 29
airsaylongcon:


Exactly why I asked. I love your question though. Very brain scratching although I'm sure I can solve it if I get to it. I'd just be lazy and get it done with excel.

Is 0813 000 0000 a valid number though? How about 0813 999 9999?
Yes, they are all valid. But it seems that network providers reserve such numbers as special numbers that can be acquired with huge price. For instance,
Airtel reserves 0802 000 0009 as their Message Centre number. MTN Message Centre number is 0803 00 0000 but they remove the last zero!
Re: Coding Ask And Answer (CAA) by asalimpo(m): 8:15pm On Apr 29
progeek37:
Here is a sample question

In Nigeria, mobile phone numbers begin with the digit 0 and can contain any digits(0,1,2,3,4,5,6,7,8,9). The first 4 digits of the numbers
determine the particular network provider. For instance, GlobalCom Nigeria Limited numbers can
begin with 0805, MTN 0803 and Airtel 0802 etc. The mobile phone numbers must
have 11 digits all together. For instance, this is my MTN number:
0813 568 3431.
Write a program that can calculate the total number of possible subscribers of
MTN numbers that begin with 0813 and print out all the numbers.


HINT
total_digits = 11: total digits of each number
digits_needed = 7: digits needed to complete 0813 to 11-digit numbers.
available_digits = 10: i.e 0,1,2,3,4,5,6,7,8,9
Note: Computer CPU has some limitations, some may not print out all the numbers. Instead of printing out all the numbers in computers with low
processor speed and RAM. Consider printing out numbers that meet some certain conditions like numbers that ends with "3431" like my number
in the question. But your program must be able to count all the total available numbers in "0813" even though it may not print them all out to the console.
Also you have to make the program flexible such that you can easily change the lines for instance, you change can "0813" to "0806", "0803", "0805", "0902" etc or even make it start with country code "+234813". Goodluck.
This ur assignment can gulp some significant lines of code. It ain't as trivial as it seems. But for the simple solution, since the first 4 digits are fixed,it remains generating the next 7, which is simply 10^7, sets. I.e 10 000 000 unique numbers including something like 0813 000 000 0 . After doing this simply append the 4 digit prefixes of ur choice . Save strings to disk.
Re: Coding Ask And Answer (CAA) by progeek37: 9:29pm On Apr 29
asalimpo:

This ur assignment can gulp some significant lines of code. It ain't as trivial as it seems. But for the simple solution, since the first 4 digits are fixed,it remains generating the next 7, which is simply 10^7, sets. I.e 10 000 000 unique numbers including something like 0813 000 000 0 . After doing this simply append the 4 digit prefixes of ur choice . Save strings to disk.
You are really thinking algorithmically! The total number of numbers of each prefix is correctly 10, 000 000. But it seems that you calculated it with basic knowledge of permutation and combination rather than from your code. The program should be able to show that the total number is 10 000 000. For instance, if you are using Python you can store all the numbers in a list, and at the end you will find the length of the list which should produce 10 000 000. However, you have taken the right approach since your program must concur with Maths calculation. But you have to think more if you want to solve the problem, because you are going to face a tougher challenge at a point. But if you think more algorithmically you can win the battle. I will not give further clues on the core logic of the problem. But let me rather give a trivial assistance: consider tackling the program functionally rather than procedurally. Define a function/method and pass to it the prefix as an argument/parameter. This will make your program flexible: you can be able to change the prefix by just calling the function/method with the needed prefix, isn't it smart?
Re: Coding Ask And Answer (CAA) by asalimpo(m): 10:06pm On Apr 29
progeek37:

You are really thinking algorithmically! The total number of numbers of each prefix is correctly 10, 000 000. But it seems that you calculated it with basic knowledge of permutation and combination rather than from your code. The program should be able to show that the total number is 10 000 000. For instance, if you are using Python you can store all the numbers in a list, and at the end you will find the length of the list which should produce 10 000 000. However, you have taken the right approach since your program must concur with Maths calculation. But you have to think more if you want to solve the problem, because you are going to face a tougher challenge at a point. But if you think more algorithmically you can win the battle. I will not give further clues on the core logic of the problem. But let me rather give a trivial assistance: consider tackling the program functionally rather than procedurally. Define a function/method and pass to it the prefix as an argument/parameter. This will make your program flexible: you can be able to change the prefix by just calling the function/method with the needed prefix, isn't it smart?
there arent many prefixes so just store them in a set. Also for the 10^7 tail numbers,use a set also to prevent accidental duplication.
They are about 4 prefixes 0816,0806,0805,0802
so prefixes=set .
TailNum=set of 10 000 000 7-digit numbers.
After generating the tail numbers, then for each prefix ,you append it to each tail num, to produce the full 11 digit phone num. In the end you should hav 4-5 * 10^7 numbers or size-of-prefix set * size-of-tail-set. The other aspects can be handled also by string manipulation. E.g deciphering numbers that begin with country code (234 ,+234) etc. It's work. You're right,aint written a line of code.
Re: Coding Ask And Answer (CAA) by progeek37: 12:02am On Apr 30
asalimpo:

there arent many prefixes so just store them in a set. Also for the 10^7 tail numbers,use a set also to prevent accidental duplication.
They are about 4 prefixes 0816,0806,0805,0802
so prefixes=set .
TailNum=set of 10 000 000 7-digit numbers.
After generating the tail numbers, then for each prefix ,you append it to each tail num, to produce the full 11 digit phone num. In the end you should hav 4-5 * 10^7 numbers or size-of-prefix set * size-of-tail-set. The other aspects can be handled also by string manipulation. E.g deciphering numbers that begin with country code (234 ,+234) etc. It's work. You're right,aint written a line of code.
You seem to be approaching the problem from a different perspective. I may not doubt its possibility of working but have you tested it to be working? Note that there can be more prefixes, 0902, 0703, 0706, 0903, 0906, 0812, 0815, 0701, 0807 etc. That is why it is better to be passing the prefix as an argument. So that anytime you need the program to find a certain prefixed-numbers you can simply pass the prefix as a parameter and call the method/function with the prefix. Prefixing is actually the most trivial part of the problem, you should first make sure the program can print all the 7-digit numbers accurately before appending the required prefix to make them 11-digits numbers. Programming is done by actual implementation. Consider writing the codes and check if everything works fine. I have attached screenshots of a sample run of my solution on my Ubuntu terminal. Note: In this screenshots, I passed "0813" prefix as an argument and print the numbers of that prefix that ends with "3431". The first screenshot shows that the first number of the 0813-numbers that ends with "3431" is "0813 000 3431" , this is correct since the first number without any attached condition is "0813 000 0000". The second screenshot shows a portion of the output where my MTN number 0813 568 3431 can be found, can you spot it out? You can also see that the total available possible numbers in the enter 0813-prefixed numbers is 10 000 000, from the screenshot. I ran the program as a module, i hid the source code. Consider writing the program with your own approach and compare with my own sample run. Thanks

Re: Coding Ask And Answer (CAA) by progeek37: 3:02pm On Apr 30
As improbable as it might seem to you, the basic principles of writing
computer programs have not changed all that much in the past 15 years.
Programming languages change, technologies get modernized, integrated
development environments get more and more advanced but the
fundamental principles of programming remain the same
. When
beginners learn to think algorithmically, and then learn to divide a problem
instinctively into a series of steps to solve it, as well as when they learn to
select the appropriate data structures and write high-quality programming
code that is when they become programmers. Once you acquire these skills,
you can easily learn new languages and various technologies.
Re: Coding Ask And Answer (CAA) by asalimpo(m): 6:58pm On Apr 30
progeek37:

You seem to be approaching the problem from a different perspective. I may not doubt its possibility of working but have you tested it to be working? Note that there can be more prefixes, 0902, 0703, 0706, 0903, 0906, 0812, 0815, 0701, 0807 etc. That is why it is better to be passing the prefix as an argument. So that anytime you need the program to find a certain prefixed-numbers you can simply pass the prefix as a parameter and call the method/function with the prefix. Prefixing is actually the most trivial part of the problem, you should first make sure the program can print all the 7-digit numbers accurately before appending the required prefix to make them 11-digits numbers. Programming is done by actual implementation. Consider writing the codes and check if everything works fine. I have attached screenshots of a sample run of my solution on my Ubuntu terminal. Note: In this screenshots, I passed "0813" prefix as an argument and print the numbers of that prefix that ends with "3431". The first screenshot shows that the first number of the 0813-numbers that ends with "3431" is "0813 000 3431" , this is correct since the first number without any attached condition is "0813 000 0000". The second screenshot shows a portion of the output where my MTN number 0813 568 3431 can be found, can you spot it out? You can also see that the total available possible numbers in the enter 0813-prefixed numbers is 10 000 000, from the screenshot. I ran the program as a module, i hid the source code. Consider writing the program with your own approach and compare with my own sample run. Thanks
I could code it up but I'm presently very busy and I don't code in Python.
It's straightforward enough that one can plot the algorithm offhead .
As for the combining d prefix and the tails (I.e the 7 digit numbers) to form a new number,11,digits, all you need is simply string concatenation. Phonenum=Prefix+ tail;
Use a loop to run thru the collection of prefixes to do the same.
Re: Coding Ask And Answer (CAA) by progeek37: 11:27pm On Apr 30
asalimpo:

I could code it up but I'm presently very busy and I don't code in Python.
It's straightforward enough that one can plot the algorithm offhead .
As for the combining d prefix and the tails (I.e the 7 digit numbers) to form a new number,11,digits, all you need is simply string concatenation. Phonenum=Prefix+ tail;
Use a loop to run thru the collection of prefixes to do the same.
Okay! When you are less busy consider writing the codes and check if everything works fine. Initially, I thought the problem was trivial but as I began to approach it, I later found out that it was not that trivial. That is the reason I'm emphasizing on writing the code to get the feel of it yourself.
Re: Coding Ask And Answer (CAA) by ab2care: 11:36pm On Apr 30
please add me on whatsapp
Re: Coding Ask And Answer (CAA) by live4dgospel(m): 8:51am On May 01
ab2care:
please add me on whatsapp
Please drop your number here or send a WhatsApp message to that my number on the sample question. And note that the WhatsApp group is in its early stage, you can add your friends who are interested in our vision. It seems that many people want to become a Web developer database scientist and app dev from day one. Only few really wants to learn programming and how algorithm works. Because of this not many people are interested in our vision however my vision is the greatest.
Re: Coding Ask And Answer (CAA) by live4dgospel(m): 8:52am On May 01
hitan:
07061836156
Please note that the WhatsApp group is in its early stage, you can add your friends who are interested in our vision. It seems that many people want to become a Web developer, database scientist and app dev from day one. Only few really wants to learn programming and how algorithm works. Because of this not many people are interested in our vision however my vision is the greatest.
Re: Coding Ask And Answer (CAA) by progeek37: 9:09am On May 01
hitan:
07061836156
I have added you.
Re: Coding Ask And Answer (CAA) by progeek37: 11:14am On May 01
Sample Question 2

In the Nigerian Federal universities, the grading system is used to calculate the performance of the students. In one particular university the grading system is as follows:

Course code: This is the shorthand representation of the course name. For instance, in the university "An Introduction To Calculus" is given the course code MTH121.

Credit hour: This is the contact hour or weight assigned to the course, as an example MTH121 is given the credit hour of 4.
Workload: Workload is the sum of all the credit hours of the courses offered by the student in a semester. Students are allowed a minimum of 15 units and maximum of 24 units per semester.

Letter grade: These are the letters attached to a score bracket. A scores within a particular range is given the same letter grade: For instance the score bracket in % of the university is given as follows: (70-100) = A, (60-69) = B, (50-59) = C, (45-49) = D, (40-44) = E and (1-39) = F.
Grade points: These are the point values assigned to eache letter grade. For instance, in the same university the grade points are as follows:
A = 5, B = 4, C = 3, D = 2, E = 1 and F = 0.

Quality point: The quality point is the product of credit hours and its corresponding grade point. This means multiplying the credit hour by its grade point. In our example, if a student scores 75 (A) in MTH121 the grade point will be 4 * 5 = 20.

Grade Point Average(GPA): This is calculated as follows, GPA = Total quality point/total workload for the semester

Cumulative Grade Point Average(CGPA): Mathematically, this is expressed as CGPA = (First semester GPA + Second semester GPA) / 2.

If you are still confused about grading system, browse the internet for details.
Note: the grading system may vary in different universities, but the algorithm for calculating GPA (grade point average) and CGPA (cumulative grade point average) remains the same.

Write a program that can calculate the GPA of any semester and the CGPA of the session, your program should be able to allow one to write the result to file and read result from file as well. You may consider making the output visually appealing by using string methods. For instance the output may appear like this:

MTH121----------------------A
PHY121---------------------- B
CHM121-------------------- D
.
.
.
GPA ------------------------3.00
Re: Coding Ask And Answer (CAA) by ab2care: 1:54pm On May 01
live4dgospel:

Please drop your number here or send a WhatsApp message to that my number on the sample question. And note that the WhatsApp group is in its early stage, you can add your friends who are interested in our vision. It seems that many people want to become a Web developer database scientist and app dev from day one. Only few really wants to learn programming and how algorithm works. Because of this not many people are interested in our vision however my vision is the greatest.
08029617975
Re: Coding Ask And Answer (CAA) by XYZeee: 4:05pm On May 01
progeek37:

I have added you.

Add me too. 08032272237, Thanks!
Re: Coding Ask And Answer (CAA) by asalimpo(m): 8:18pm On May 01
progeek37:

Okay! When you are less busy consider writing the codes and check if everything works fine. Initially, I thought the problem was trivial but as I began to approach it, I later found out that it was not that trivial. That is the reason I'm emphasizing on writing the code to get the feel of it yourself.
Actually this is toy stuff to an experienced hand. It will b tedious but not something to take up much time. Max a few hours. Nothing when compared to projects that chew up months of time. It's unfortunate what nl is despite being a programmer section. It lacks facilities for programmers!
Re: Coding Ask And Answer (CAA) by Tosineb: 5:48pm On May 02
I'm interested in this 08035022501
Re: Coding Ask And Answer (CAA) by Tosineb: 5:48pm On May 02
I'm interested in this 08035022501
Re: Coding Ask And Answer (CAA) by charliboy654(m): 7:25pm On May 02
asalimpo:

I could code it up but I'm presently very busy and I don't code in Python.
It's straightforward enough that one can plot the algorithm offhead .
As for the combining d prefix and the tails (I.e the 7 digit numbers) to form a new number,11,digits, all you need is simply string concatenation. Phonenum=Prefix+ tail;
Use a loop to run thru the collection of prefixes to do the same.
I bet u use JavaScript
Re: Coding Ask And Answer (CAA) by modestbrowser(m): 8:20pm On May 02
Some people forming prof saying this ain't worth their time. Wish to be like u guys some day.
Well.... Op see this.... quoted u in second page

Question 1







Question 2

Note: I purposely reduced the number of possible number combinations because of JavaScript couldn't do 10million numbers on
chrome at ease.... I reduced the number to not greater than X*10,000,111



Re: Coding Ask And Answer (CAA) by Woqhub: 8:30pm On May 02
07060601229 add me, lets code and solve problems am ready yo learn more
Re: Coding Ask And Answer (CAA) by charliboy654(m): 8:45pm On May 02
08140231279
Re: Coding Ask And Answer (CAA) by progeek37: 9:10pm On May 02
modestbrowser:
Let me solve your questions
Okay. Please after solving it consider sharing the screenshots of the sample run of the program. Thanks

(1) (2) (3) (4) (Reply)

I Need A Code To Allow Download From / MESA Compile? / Please Help On How To Insert Smiley In An Output Text In Java Script

(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: (0) (1) (2) (3) (4) (5) (6) (7) (8) (9)

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