Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,154,495 members, 7,823,158 topics. Date: Friday, 10 May 2024 at 04:55 AM |
Nairaland Forum / Science/Technology / Programming / A Thread For Competitive Programming (1836 Views)
Competitive Programming / Thread For Competitive Programming / A Thread For Tutorial On Python Programming (2) (3) (4)
Re: A Thread For Competitive Programming by logicDcoder(m): 8:49pm On Feb 01, 2021 |
Question 1 and 3 Solved Observation: Only even numbers can be perfect! SUPREMOTM 404Dev iAmChidiebere mention others please! 1 Like
|
Re: A Thread For Competitive Programming by SUPREMOTM: 4:26pm On Feb 02, 2021 |
QUESTION 1 LANGUAGE JavaScript IDE: Visual Studio Code Since no factor of a number can be greater than half of the number, besides itself, I made the loop control variable have a maximum value of half the number. So as to be able to test the function with valid perfect numbers, I had to also create a function that gets all the perfect numbers from 1 to 100000, the function returned 4 numbers. The results of the tests are displayed on Chrome browser console window. 1 Like
|
Re: A Thread For Competitive Programming by logicDcoder(m): 10:04pm On Feb 02, 2021 |
SUPREMOTM: I really learnt something here kudos boss! |
Re: A Thread For Competitive Programming by Excallibur(m): 12:22am On Feb 03, 2021 |
number 1 in python
|
Re: A Thread For Competitive Programming by iAmChidiebere: 6:52am On Feb 03, 2021 |
logicDcoder: Question 1. Python
|
Re: A Thread For Competitive Programming by iAmChidiebere: 7:12am On Feb 03, 2021 |
Question 2 Java 1 Like
|
Re: A Thread For Competitive Programming by iAmChidiebere: 7:20am On Feb 03, 2021 |
SUPREMOTM:Nice one boss!... used same thought. |
Re: A Thread For Competitive Programming by iAmChidiebere: 7:21am On Feb 03, 2021 |
logicDcoder:Nice one guy. |
Re: A Thread For Competitive Programming by iAmChidiebere: 7:22am On Feb 03, 2021 |
Number 3.... when nepa brings light |
Re: A Thread For Competitive Programming by iAmChidiebere: 7:26am On Feb 03, 2021 |
Excallibur:Nice bro... Can be more efficient though 1 Like |
Re: A Thread For Competitive Programming by Excallibur(m): 10:33am On Feb 03, 2021 |
iAmChidiebere:Thanks bro 1 Like |
Re: A Thread For Competitive Programming by logicDcoder(m): 12:03pm On Feb 03, 2021 |
iAmChidiebere:Kudos boss! 1 Like |
Re: A Thread For Competitive Programming by logicDcoder(m): 12:04pm On Feb 03, 2021 |
iAmChidiebere:I can't wait ooo |
Re: A Thread For Competitive Programming by iAmChidiebere: 4:38pm On Feb 03, 2021 |
logicDcoder:In a bit boss |
Re: A Thread For Competitive Programming by iAmChidiebere: 6:06pm On Feb 03, 2021 |
iAmChidiebere:Python 1st image: Redundant comments for the sake of newbies 2nd image: Reduced comments. More tidy 3rd image: Execution Cc: logicDcoder 1 Like
|
Re: A Thread For Competitive Programming by SUPREMOTM: 12:12am On Feb 04, 2021 |
QUESTION 2 LANGUAGE: Javascript IDE: Visual Studio Code Chrome browser console is used to test the function. 1. First, I create a while loop with values ranging from the the lower parameter to the higher parameter of the function. 2. For each of the values of the control variable in the while loop, I get the sum of its factors (otherNumber); then I reverse the process immediately (I get the sum of the factor of otherNumber (testForAmicability) and check to see if it is equal to the loop control variable(startValue)). 3. If the test performed in 2 above shows the two numbers are equal, I append the two values to the return value of the function (AmicableResult); 4. I increment the loop control variable by 1 and repeat the steps (2 and 3 above).
|
Re: A Thread For Competitive Programming by SUPREMOTM: 12:14am On Feb 04, 2021 |
QUESTION 1 LANGUAGE: C# IDE: Visual Studio Pseudocode: Mostly same as for JavaScript I created a function GetPerfectNumbers( ), so as to have an idea of the numbers that should return true. I created a function IsPerfectNumber( ) that takes the number to test as an argument. If the test number is a perfect number, it returns true. I made it into a desktop application, so, after several test numbers are typed in a textbox, separated by commas and the button is clicked, the boolean values representing the return value of the function for each of the numbers is displayed beside the number.
|
Re: A Thread For Competitive Programming by SUPREMOTM: 12:18am On Feb 04, 2021 |
QUESTION 2 LANGUAGE: C# IDE: Visual Studio Pseudocode: Mostly same as for JavaScript Whenever the button is clicked, the function AmicableNumbers( ) is invoked and the list of amicable numbers in the specified range is written to a notepad file on my desktop.
|
Re: A Thread For Competitive Programming by logicDcoder(m): 4:07pm On Feb 04, 2021 |
iAmChidiebere:Nice one boss. |
Re: A Thread For Competitive Programming by iAmChidiebere: 7:36pm On Feb 04, 2021 |
logicDcoder:Thanks boss |
Re: A Thread For Competitive Programming by logicDcoder(m): 8:01am On Feb 05, 2021 |
Week 2 -> Bonus Problem: Honorable Mentions: SUPREMOTM iAmChidiebere 404Dev Excallibur
|
Re: A Thread For Competitive Programming by iAmChidiebere: 2:12pm On Feb 05, 2021 |
logicDcoder:PYTHON Pseudo-code Check if the acc balance is enough to make 1 minute of call. If it can't, return 0. Otherwise, set the number of minutes to 1 and subtract the call rate from the acc balance Next, check if the money left in the acc balance can make up to 9 minutes of call, using the call rate for 2nd to 10th minute. If it can't, check how many minutes it can then make, add it to the number of minutes, and then, return the summed value. Otherwise, increase the number of minutes by 9, and then subtract the call rate for 9 minutes from the acc balance. Next, use the call rate for 11th minute and above to get the amount of minutes that the remaining acc balance can make and add it to the number of minutes previously calculated. Return the summed value.
|
Re: A Thread For Competitive Programming by SUPREMOTM: 10:19pm On Feb 05, 2021 |
Week2 Bonus Question Language: Javascript Google Chrome console is used for testing the function. First calculate the amount of money needed to make calls for 10 minutes, store it in a variable, cost10. After that, there are only 2 conditions to check for in this order. 1. Is your account balance greater than cost10? If yes, the time is (your balance minus cost for first 10 minutes divided by the charges for 11th minute and above) plus 10. ==>time2 2. Is your account balance greater than or equal to the cost for a minute of call? If yes, the time is (your balance minus cost for 1st minute divided by the charges for 2nd to 10th minute) plus 1. ==>time1 If it doesn't satisfy any of the two conditions above, you have 0.
|
C# Programmer's Club / Thread closed. / Nairaland Programming Contest (8-Puzzle)
(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. 32 |