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


Learning Strings and binary numbers @ Dcoder

17 Jul 2023 1 minute read 0 comments Lochard

Problem: Given two binary strings, A (of length 10) and B (of length 5), output 1 if B is a substring of A and 0 otherwise. Input: Binary string A and B separated by a space. Output: The logical value of: 'B is a substring of A'.  ie. 1 if B is subst...

Dcooooooooooder Fan @ Dcoder

17 Jul 2023 1 minute read 0 comments Lochard

Problem: Print the word Dco...oder Input: A positive integer n Output: Print the word: Dco..oder(letter o must be repeted n times) Constraints: 0

The light Switch @ Dcoder

16 Jul 2023 1 minute read 0 comments Lochard

Problem: There is a light bulb on the stairs, which has two switches. The light turns on if and only if one of them is on(binary 1) and other is off(binary 0).You are given combinations of these switch find whether the bulb glow or not? Input: Two bi...

Learn Sum of numbers @ Dcoder

15 Jul 2023 1 minute read 0 comments Lochard

Problem: Given 2 natural numbers, find sum of them. Input: Two natural numbers n1 and n2 separated by a space. Output: Sum of the numbers Constraints: 1

Sum of squares @ Dcoder

14 Jul 2023 1 minute read 0 comments Lochard

Problem: Compute the sum of squares for the given numbers: a, a+1, ..., b-1, b. Input: Two natural numbers a and b separated by a space. Output: Computed sum: a*a + (a+1)*(a+1) + ... + (b-1)*(b-1) + b*b Constraints: 1

The Triangle Game @ Dcoder

13 Jul 2023 1 minute read 2 comments Lochard

Problem: Glin was doing his maths homework , Rick came to his house. As Glin is week at Maths, Rick decided to help him in his homework. They both stuck at a problem of Right Angle Triangle. You have to help them both in this problem. Input is a Stri...

CodeWars C Kata - Double Char

12 Jul 2023 1 minute read 0 comments Lochard

DESCRIPTION: Given a string, you have to return a string in which each character (case-sensitive) is repeated once.   Examples (Input -> Output): * "String" -> "SSttrriinngg" * "Hello World" -> "HHeelllloo WWoorrlldd" * "1234!_ " -> "11223344!!__ " c...

The sum of Array @ Dcoder

11 Jul 2023 1 minute read 0 comments Lochard

Problem: Given the array of N numbers, you have to find its sum. Input: The first line contains an integer N, number of elements in array.Next line contains N integers separated by space. Output: Print the sum of the array's elements. Constraints: 1

The War of Problem Setters @ Dcoder

10 Jul 2023 1 minute read 0 comments Lochard

Problem: Garry and Sharry are colleague, assuming they work at Dcoder. They are our Problem Setters.One day we decide to judge their work. Both were given an assignment to make some problems to display at Dcoder, and they were awarded points based on...

Avik and his Girlfriend's Necklace @ Dcoder

9 Jul 2023 1 minute read 0 comments Lochard

Problem: Avik's Girlfriend is a Sorted Girl and she is also a Coder and loves arrays. So on her birthday Avik decided to gift her a necklace of pearls, now these pearls have numbers printed on them. When he bought the necklace its pearls were in sort...