As a newbie programmer
As a newbie programmer

As a newbie programmer

Sharing entry level codes. My snippets on GitHub https://github.com/locharp/code-snippets


Codewars 6 kyu Kata - Multiples of 3 or 5

28 Jul 2023 1 minute read 0 comments Lochard

DESCRIPTION: If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.   Finish the solution so that it returns the sum of all the multiples of 3 or 5 below the number passed in....

Print Hello World @ Dcoder

28 Jul 2023 1 minute read 0 comments Lochard

Problem: Alice recently discovered programming.Help Alice to code her first Program. Input:  Output: Hello World Constraints:  Sample Input:  Sample Output:  Hello World print ("Hello World")

Printing number using loop @ Dcoder

26 Jul 2023 1 minute read 0 comments Lochard

Problem: Ariel & Eric have a child, help them teaching him Counting from 1 to 10. Input:  Output: Output should be 1 to 10 separated with a new line character "\n" Constraints:  Sample Input:  Sample Output:  1 2 3 4 5 6 7 8 9 10 for i in range(1, 11...

Learning User Input with Natural Numbers @ Dcoder

25 Jul 2023 1 minute read 0 comments Lochard

Problem: The numbers 1,2,3.. are known as Natural numbers. Calculate the sum of all the natural numbers from 1 to N, where N will be the input. Input: A positive integer N Output: Output will be sum of numbers from 1 to N Constraints: 1

Learning Factorials with Loop/Recursion @ Dcoder

24 Jul 2023 1 minute read 0 comments Lochard

Problem: If n is an integer greater than 0, n factorial (n!) is the product: n* (n-1) * (n-2) * ( n-3)… * By convention, 0! = 1. Write a Program to compute n Factorial(n!), where n is input.  Input: n is a positive integer Output: Output will be n fa...

How many weeks @ Dcoder

23 Jul 2023 1 minute read 0 comments Lochard

Problem: A town in Death Valley has a water tank that contains 10,000 gallons of water. If there is no rain, calculate the number of weeks the water will last for an input weekly water usage. Input: Input contains positive integer n , which indicates...

The shortest Path Algo(Simple) @ Dcoder

22 Jul 2023 1 minute read 0 comments Lochard

Problem: The Jones Trucking Company tracks the location of each of its trucks on a grid similar to an (x, y) plane. The home office is at location (0, 0). Read the coordinates of truck A and the coordinates of truck B and determine which is closer to...

The BlackJack with conditions. @ Dcoder

21 Jul 2023 1 minute read 0 comments Lochard

Problem: Write a program to play a variety of BlackJack. In general, given two numbers, a and b, return their sum. If the sum is greater than 21, return 0, unless one of the numbers is 11. In such a case, the 11 should be 'converted' to a 1 to preven...

Learning Prime numbers with Loop/Recursion @ Dcoder

20 Jul 2023 1 minute read 0 comments Lochard

Problem: Raja Beta is bad at maths, his teacher always complaints about him.Help him in his prime numbers homework. Input: Two space separated positive integer m and n Output: Print all prime numbers p such that m

Learning sorting numbers with if else @ Dcoder

18 Jul 2023 1 minute read 0 comments Lochard

Problem: There are 3 numbers given as input sort them in increasing order. Input: Three space separated positive integer m,n,p Output: Print the integers in sorted incresing order separated by space. Constraints: 0