Weekend batch
Hemant Deshpande, PMP has more than 17 years of experience working for various global MNC's. He has more than 10 years of experience in managing large transformation programs for Fortune 500 clients across verticals such as Banking, Finance, Insurance, Healthcare, Telecom and others. During his career he has worked across the geographies - North America, Europe, Middle East, and Asia Pacific. Hemant is an internationally Certified Executive Coach (CCA/ICF Approved) working with corporate leaders. He also provides Management Consulting and Training services. He is passionate about writing and regularly blogs and writes content for top websites. His motto in life - Making a positive difference.
Your One-Stop Solution to Understand Coin Change Problem
Combating the Global Talent Shortage Through Skill Development Programs
What Is Problem Solving? Steps, Techniques, and Best Practices Explained
One Stop Solution to All the Dynamic Programming Problems
The Ultimate Guide to Top Front End and Back End Programming Languages for 2021
Learning objectives.
The goal of this book is to teach you to solve computational problems and to think like an engineer. Computational problems are problems that can be solved by the use of computations (a computation is what you do when you calculate something). Engineers are people who solve problems – they invent, design, analyze, build and test “things” to fulfill objectives and requirements. The single most important skill for you to learn is problem solving. Problem solving means the ability to formulate problems, think creatively about solutions, and express a solution clearly and accurately. As it turns out, the process of learning to program is an excellent opportunity to practice problem-solving skills.
This book strives to prepare you to write well-designed computer programs that solve interesting problems involving data.
Figure 1: “The seven components to computational thinking”(www.ignitemyfutureinschool.org/about)
Computational Thinking is the thought processes involved in understanding a problem and expressing its solution in a way that a computer can effectively carry out. Computational thinking involves solving problems, designing systems, and understanding human behavior (e.g. what the user needs or wants) – thinking like an engineer. Computational thinking is a fundamental skill for everyone, not just for programmers because computational thinking is what comes before any computing technology. [1]
Computer science is the study of computation — what can be computed and how to compute it whereas computational thinking is:
Conceptualizing , not programming. Computer science is not only computer programming. Thinking like a computer scientist means more than being able to program a computer. It requires thinking at multiple levels of abstraction;
Fundamental , not rote skill. A fundamental skill is something every human being must know to function in modern society. Rote means a mechanical routine;
A way that humans, not computers, think . Computational thinking is a way humans solve problems; it is not trying to get humans to think like computers. Computers are dull and boring; humans are clever and imaginative. We humans make computers exciting. Equipped with computing devices, we use our cleverness to tackle problems we would not dare take on before the age of computing and build systems with functionality limited only by our imaginations;
Complements and combines mathematical and engineering thinking . Computer science inherently draws on mathematical thinking, given that, like all sciences, its formal foundations rest on mathematics. Computer science inherently draws on engineering thinking, given that we build systems that interact with the real world;
Ideas , not artifacts. It’s not just the software and hardware artifacts we produce that will be physically present everywhere and touch our lives all the time, it will be the computational concepts we use to approach and solve problems, manage our daily lives, and communicate and interact with other people;
For everyone, everywhere . Computational thinking will be a reality when it is so integral to human endeavors it disappears as an explicit philosophy. [2]
Figure 2 “Are you happy?” by Typcut http://www.typcut.com/headup/are-you-happy
An algorithm specifies a series of steps that perform a particular computation or task. Throughout this book we’ll examine a number of different algorithms to solve a variety of computational problems.
Algorithms resemble recipes. Recipes tell you how to accomplish a task by performing a number of steps. For example, to bake a cake the steps are: preheat the oven; mix flour, sugar, and eggs thoroughly; pour into a baking pan; set the timer and bake until done.
However, “algorithm” is a technical term with a more specific meaning than “recipe”, and calling something an algorithm means that the following properties are all true:
Once we know it’s possible to solve a problem with an algorithm, a natural question is whether the algorithm is the best possible one. Can the problem be solved more quickly or efficiently?
The first thing you need to do before designing an algorithm is to understand completely the problem given. Read the problem’s description carefully, then read it again. Try sketching out by hand some examples of how the problem can be solved. Finally consider any special cases and design your algorithm to address them.
An algorithm does not solve a problem rather it gives you a series of steps that, if executed correctly, will result in a solution to a problem.
Let us look at a very simple algorithm called find_max.
Problem : Given a list of positive numbers, return the largest number on the list.
Inputs : A list of positive numbers. This list must contain at least one number. (Asking for the largest number in a list of no numbers is not a meaningful question.)
Outputs : A number, which will be the largest number in the list.
Algorithm :
Does this meet the criteria for being an algorithm?
[3] Figure 3: Example Algotithm
How do we know if an algorithm is unambiguous, correct, comes to an end, is general AND is at the right level of detail? We must test the algorithm. Testing means verifying that the algorithm does what we expect it to do. In our ‘bake a cake’ example we know our algorithm is ‘working’ if, in the end, we get something that looks, smells and tastes like a cake.
Figure 4 “ Keyboard ” by Geralt is licensed under CC 2
Your first step should be to carefully read through EACH step of the algorithm to check for ambiguity and if there is any information missing. To ensure that the algorithm is correct, terminates and is general for any input we devise ‘test cases’ for the algorithm.
A test case is a set of inputs, conditions, and expected results developed for a particular computational problem to be solved. A test case is really just a question that you ask of the algorithm (e.g. if my list is the three numbers 2, 14, and 11 does the algorithm return the number 14?). The point of executing the test is to make sure the algorithm is correct, that it terminates and is general for any input.
Good (effective) test cases:
Let us look at the example algorithm from the previous section. The input for the algorithm is ‘a list of positive numbers’. To make it easy to understand and execute keep the test lists short. The preconditions are that the list only contains numbers and these numbers must be positive so include a test with a ‘non-number’ (i.e. a special character or a letter) and a test with a negative number. The boundaries for the list are zero and the highest positive number so include a test with zero and a large positive number. That is it! Here is an example of three different test cases.
|
|
|
1 | List: 44, 14, 0, 1521, 89, 477 | 1521 |
2 | List: 18, 4, 72, *, 31 | Error (or no result) |
3 | List: 22, -9, 52 | Error (or no result) |
Manually, you should step through your algorithm using each of the three test cases, making sure that the algorithm does indeed terminate and that you get your expected result. As our algorithms and programs become more complex, skilled programmers often break each test case into individual steps of the algorithm/program and indicate what the expected result of each step should be. When you write a detailed test case, you don’t necessarily need to specify the expected result for each test step if the result is obvious.
In computer programming we accept a problem to solve and develop an algorithm that can serve as a general solution. Once we have such a solution, we can use our computer to automate the execution. Programming is a skill that allows a competent programmer to take an algorithm and represent it in a notation (a program) that can be followed by a computer. These programs are written in programming languages (such as Python). Writing a correct and valid algorithm to solve a computational problem is key to writing good code. Learn to Think First and coding will come naturally!
Computational problem solving does not simply involve the act of computer programming. It is a process, with programming being only one of the steps. Before a program is written, a design for the program must be developed (the algorithm). And before a design can be developed, the problem to be solved must be well understood. Once written, the program must be thoroughly tested. These steps are outlined in Figure 5.
Figure 5: Process of Computational Problem Solving
A value is one of the basic things computer programs works with, like a password or a number of errors.
Values belong to different types: 21 is an integer (like the number of errors), and ‘comp15’ is a string of characters (like the password). Python lets you give names to values giving us the ability to generalize our algorithms.
One of the most powerful features of a programming language is the ability to use variables. A variable is simply a name that refers to a value as shown below,
variable is assigned the value 21 | |
variable is assigned the value ‘comp15’ |
Whenever the variable errors appears in a calculation the current value of the variable is used.
variable is assigned the value 21 | |
variable is assigned the value of 21+1 (22) |
We need some way of storing information (i.e. the number of errors or the password) and manipulate them as well. This is where variables come into the picture. Variables are exactly what the name implies – their value can vary, i.e., you can store anything using a variable. Variables are just parts of your computer’s memory where you store some information. Unlike literal constants, you need some method of accessing these variables and hence you give them names.
Programmers generally choose names for their variables that are meaningful and document what the variable is used for. It is a good idea to begin variable names with a lowercase letter . The underscore character (_) can appear in a name and is often used in names with multiple words.
Figure 6: “ Python Code ” by nyuhuhuu is licensed under CC-BY 2.0
A program is a sequence of instructions that specifies how to perform a computation. The computation might be something mathematical, such as solving a system of mathematical equations or finding the roots of a polynomial, but it can also be a symbolic computation, such as searching and replacing text in a document or something graphical, like processing user input on an ATM device.
The details look different in different computer programming languages, but there are some low-level conceptual patterns (constructs) that we use to write all programs. These constructs are not just for Python programs, they are a part of every programming language.
input Get data from the “outside world”. This might be reading data from a file, or even some kind of sensor like a microphone or GPS. In our initial algorithms and programs, our input will come from the user typing data on the keyboard.
output Display the results of the program on a screen or store them in a file or perhaps write them to a device like a speaker to play music or speak text.
sequential execution Perform statements one after another in the order they are encountered in the script.
conditional execution Checks for certain conditions and then executes or skips a sequence of statements.
repeated execution Perform some set of statements repeatedly, usually with some variation.
reuse Write a set of instructions once and give them a name and then reuse those instructions as needed throughout your program.
Believe it or not, that’s pretty much all there is to it. Every computer application you’ve ever used, no matter how complicated, is made up of constructs that look pretty much like these. So you can think of programming as the process of breaking a large, complex task into smaller and smaller subtasks until the subtasks are simple enough to be performed with one of these basic constructs. The “art” of writing a program is composing and weaving these basic elements together many times over to produce something that is useful to its users.
The key to better algorithm design and thus to programming lies in limiting the control structure to only three constructs as shown below.
Figure 7: the 3 Programming Constructs
Let us look at some examples for the sequential control and the selection control.
The following algorithm is an example of sequential control .
Problem : Given two numbers, return the sum and the product of the two numbers.
Inputs : Two numbers.
Outputs : The sum and the product.
Here is an example of three different test cases that are used to verify the algorithm.
|
|
|
1 | numbers 0 and 859 | sum is 859 |
2 | numbers -5 and 10 | sum is 5 |
3 | numbers 12 and 3 | sum is 15 |
The following two algorithms are examples of selection control which uses the ‘IF’ statement in most programming languages.
Problem : Given two numbers, the user chooses to either multiply, add or subtract the two numbers. Return the value of the chosen calculation.
Inputs : Two numbers and calculation option.
Outputs : The value of the chosen calculation.
The relational (or comparison) operators used in selection control are:
= is equal to [in Python the operator is ==]
> is greater than
< is less than
>= is greater than or equal
<= is less than or equal
<> is not equal to [in Python the operator is !=]
|
|
|
1 | choice ‘a’ | answer is 20 |
2 | choice ‘s’ | answer is 2012 |
3 | choice ‘**’ | answer is NONE |
This example uses an extension of the simple selection control structure we just saw and is referred to as the ‘IF-ELSE’ structure.
Problem : Accept from the user a positive integer value representing a salary amount, return tax due based on the salary amount.
Inputs : One positive integer number.
Outputs : The calculated tax amount.
= is equal to [in Python the operator is ==]
<> is not equal to [in Python the operator is !=]
|
|
|
1 | salary of 0 | tax is 0 |
2 | salary of 75000 | tax is 2500 |
3 | salary of 120000 | tax is 30000 |
The third programming control is the iterative or, also referred to as, the repetition structure. This control structure causes certain steps to be repeated in a sequence a specified number of times or until a condition is met. This is what is called a ‘loop’ in programming
In all programming languages there are generally two options: an indefinite loop (the Python ‘WHILE’ programming statement) and a definite loop (the Python ‘FOR’ programming statement). We can use these two constructs, WHILE and FOR, for iterations or loops in our algorithms.
Note for Reader: A definite loop is where we know exactly the number of times the loop’s body will be executed. Definite iteration is usually best coded as a Python for loop. An indefinite loop is where we do not know before entering the body of the loop the exact number of iterations the loop will perform. The loop just keeps going until some condition is met. A while statement is used in this case.
The following algorithm is an example of iterative control using WHILE .
Problem : Print each keyboard character the users types in until the user chooses the ‘q’ (for ‘quit’) character.
Inputs : A series of individual characters.
Outputs : Each character typed in by the user.
|
|
|
1 | letter ‘z’ | The character you typed is z. |
2 | letter ‘8’ | The character you typed is 8 |
3 | letter ‘q’ | The character you typed is q. |
The following algorithm is an example of iterative control using FOR . This statement is used when the number of iterations is known in advance.
Problem : Ask the user how many words they want to enter then print the words entered by the user.
Inputs : Number of words to be entered; this value must be a positive integer greater than zero. Individual words.
Outputs : Each word typed in by the user.
Here is an example of two different test cases that are used to verify the algorithm.
|
|
|
1 | num_words 1 | The word you entered is ‘code’. |
2 | num_words 3 | The word you entered is ‘coding’. |
Figure8: iPhone apps by Jaap Arriens/NurPhoto via Getty Images (abcnews.go.com)
You see computer programming in use every day. When you use Google or your smartphone, or watch a movie with special effects, there is programing at work. When you order a product over the Internet, there is code in the web site, in the cryptography used to keep your credit card number secure, and in the way that UPS routes their delivery vehicle to get your order to you as quickly as possible.
Programming is indeed important to an informatics professional as they are interested in finding solutions for a wide variety of computational problems involving data.
When you Google the words “pie recipe,” Google reports that it finds approximately 38 million pages, ranked in order of estimated relevance and usefulness. Facebook has approximately 1 billion active users who generate over 3 billion comments and “Likes” each day. GenBank, a national database of DNA sequences used by biologists and medical researchers studying genetic diseases, has over 100 million genetic sequences with over 100 billion DNA base pairs. According to the International Data Corporation, by 2020 the digital universe – the data we create and copy annually – will reach 44 zettabytes, or 44 trillion gigabytes.
Figure 9: The Digital Universe ( www.emc.com/leadership/digital-universe/2014iview/images )
Doing meaningful things with data is challenging, even if we’re not dealing with millions or billions of things. In this book, we will be working with smaller sets of data. But much of what we’ll do will be applicable to very large amounts of data too.
Computational Thinking is the thought processes involved in formulating a problem and expressing its solution in a way that a computer—human or machine—can effectively carry out.
Computational Thinking is what comes before any computing technology—thought of by a human, knowing full well the power of automation.
Writing a correct and valid algorithm to solve a computational problem is key to writing good code.
>= 0.9 | A |
>= 0.8 | B |
>= 0.7 | C |
>= 0.6 | D |
< 0.6 | E |
Privacy Policy
Varun Saharawat is a seasoned professional in the fields of SEO and content writing. With a profound knowledge of the intricate aspects of these disciplines, Varun has established himself as a valuable asset in the world of digital marketing and online content creation.
Solving Basic Programming Problems is the key to achieve success in coding challenges. Students must practice these basic programming problems!
Basic Programming Problems: Engaging in code challenges offers many benefits, serving as a dynamic tool to enhance problem-solving proficiency, deepen your comprehension of the programming language you work with, and acquaint yourself with diverse algorithms. If you aspire to elevate your programming skills, immersing yourself in coding is the most effective avenue.
The beauty of basic programming problems lies in their convenience—they provide a platform to hone your abilities through bite-sized problems, often eliminating the need to construct entire applications. This characteristic allows you to conquer these challenges swiftly, fostering a sense of accomplishment.
Moreover, code challenges are integral components of many coding interviews.
While your resume may showcase your skills and ability to articulate programming concepts, employers want to validate your practical coding capabilities. Tackling coding challenges during interviews becomes a testament to your proficiency and showcases your competence for the role.
Therefore, incorporating coding challenges into your routine sharpens your skills and is an invaluable preparation strategy for job interviews. To kickstart your coding journey, we have curated a collection of popular basic programming problems to pave the way for your continued growth.
Table of Contents
Basic programming problems provide an essential foundation for individuals learning to code, offering a practical and hands-on approach to mastering fundamental concepts in programming.
These problems are designed to introduce beginners to the core coding principles, gradually building their problem-solving skills and comprehension of programming logic.
Whether you are a novice looking to embark on your coding journey or an experienced programmer aiming to reinforce your foundational knowledge, engaging with basic programming problems is a valuable practice.
These problems typically cover essential topics such as data types, loops, conditionals, functions, and basic algorithms, providing a well-rounded introduction to the key building blocks of programming.
The significance of basic programming problems extends beyond mere skill development; it serves as a stepping stone for individuals aspiring to pursue more advanced coding challenges and projects.
By grappling with these foundational problems, learners can cultivate a solid understanding of programming fundamentals, laying the groundwork for future exploration and mastery of more complex coding concepts. Basic programming problems are the cornerstone of a programmer’s educational journey, fostering a strong and resilient coding skill set.
Starting your career in the programming field is exciting and challenging. For beginners, mastering the basics is crucial, and what better way to do so than by solving basic programming problems ?
1 | Hello World: Print “Hello, World!” to the console. |
2 | Sum of Two Numbers: Add two numbers and print the result. |
3 | Factorial of a Number: Calculate the factorial of a number. |
4 | Check Even or Odd: Determine if a number is even or odd. |
5 | Reverse a String: Reverse the characters in a given string. |
6 | Fibonacci Series: Generate the Fibonacci series. |
7 | Check Prime Number: Check if a number is prime. |
8 | Find Maximum Element: Find the maximum element in an array. |
9 | Palindrome Check: Check if a string is a palindrome. |
10 | Simple Calculator: Implement a basic calculator. |
11 | Find Minimum Element: Find the minimum element in an array. |
Here are some of the basic programming problems JAVA :
1) Hello World:
public class HelloWorld {
public static void main(String[] args) {
System.out.println(“Hello, World!”);
2) The sum of Two Numbers:
Add two numbers and print the result.
public class Sum {
int num1 = 5, num2 = 10, sum;
sum = num1 + num2;
System.out.println(“Sum: ” + sum);
3) Factorial of a Number:
Calculate the factorial of a number.
public class Factorial {
int num = 5;
long factorial = 1;
for (int i = 1; i <= num; ++i) {
factorial *= i;
System.out.println(“Factorial: ” + factorial);
4) Check Even or Odd:
Determine if a number is even or odd.
public class EvenOdd {
int num = 8;
if (num % 2 == 0) {
System.out.println(num + ” is even.”);
} else {
System.out.println(num + ” is odd.”);
5) Reverse a String:
Reverse the characters in a given string.
public class ReverseString {
String str = “Hello”;
StringBuilder reversed = new StringBuilder(str).reverse();
System.out.println(“Reversed String: ” + reversed);
Here are some theory-based basic programming problems Java:
1) Differences Between C++ and Java
Languages Compatibility:
Interaction with the Library:
Characteristics:
Semantics of the Type:
Compiler and Interpreter:
2) Features of the Java Programming Language:
3) ClassLoader in Java:
4) Differences Between Heap and Stack Memory in Java:
Embark on a transformative journey with our comprehensive course, “ Decode Java+DSA 1.0 ,” meticulously designed to empower you with the skills needed to excel in programming. This course seamlessly integrates Core Java and Data Structures and Algorithms (DSA), offering a holistic learning experience that lays a robust foundation for your programming journey.
Key Features:
Who Should Enroll:
Upon completion of “ Decode Java+DSA 1.0 ,” by PW you’ll emerge as a proficient programmer equipped with the skills to tackle diverse programming challenges. Whether you’re aiming to kickstart your programming career, enhance your academic pursuits, or upskill for professional growth, this course is your gateway to mastering Java and DSA. Elevate your programming prowess and embark on a journey of continuous learning and innovation.
The table below shows the basic programming problems in C :
1. Hello World | Print “Hello, World!” to the console. | Output: Hello, World! |
2. Sum of Two Numbers | Take two numbers and print their sum. | Input: 5, 7; Output: 12 |
3. Factorial Calculation | Calculate and print the factorial of a number. | Input: 5; Output: 120 |
4. Check Even or Odd | Determine if a number is even or odd. | Input: 8; Output: Even |
5. Swap Two Numbers | Take two numbers and swap their values. | Input: 3, 7; Output: 7, 3 |
6. Prime Number Check | Check if a number is prime or not. | Input: 11; Output: Prime |
7. Reverse a Number | Reverse the digits of a number. | Input: 123; Output: 321 |
8. Palindrome Check | Check if a number is a palindrome. | Input: 121; Output: Palindrome |
9. Fibonacci Series | Print Fibonacci series. | Input: 5; Output: 0, 1, 1, 2, 3 |
10. Leap Year Check | Check if a year is a leap year. | Input: 2020; Output: Leap Year |
Put your learning into action with hands-on projects that simulate real-world scenarios with Decode Full Stack Web Dev 1.0 by PW . From designing responsive user interfaces to implementing robust server-side functionalities, you’ll gain practical experience that enhances your proficiency.
Learn essential tools like Git for version control, ensuring collaborative and efficient development. Explore deployment strategies to showcase your applications to the world, covering platforms like Heroku.
Who Should Enroll
In addition to introducing you to Python’s syntax and structure, tackling basic programming problems in Python helps you improve your problem-solving skills. With tasks ranging from basic logic puzzles to intricate algorithmic difficulties, these issues offer an interactive method of learning Python and put you on the route to becoming a skilled programmer.
Hello World | Write a program that prints “Hello, World!” to the console. |
Variables and Data Types | Create variables of different data types (integers, floats, strings) and perform basic operations on them. |
Conditional Statements | Use if, elif, and else statements to implement basic conditional logic. |
Loops | Implement loops (for, while) to iterate through lists, perform a certain action, or solve iterative problems. |
Lists and Arrays | Manipulate lists and arrays: create, access, modify, and traverse elements. |
Functions | Define and call functions with parameters and return values. |
File Handling | Read from and write to files, handle exceptions for file operations. |
Exception Handling | Use try, except, finally blocks to handle exceptions and errors gracefully. |
Basic Algorithms | Implement basic algorithms such as sorting (e.g., bubble sort) searching (e.g., linear search) |
Recursion | Solve problems using recursive functions. |
Object-Oriented Programming (OOP) | Create classes, objects, and methods; implement inheritance and encapsulation. |
Regular Expressions | Use regular expressions for pattern matching and text manipulation. |
List Comprehensions | Write concise and expressive code using list comprehensions. |
Lambda Functions | Define anonymous functions using lambda expressions. |
Error Handling and Logging | Handle errors effectively and implement logging for debugging. |
Basic Input/Output | Take user input and display output using input() and print(). |
Virtual Environment and Packages | Create virtual environments and install external packages using pip. |
Whether you aim to enhance your web development skills or explore the vast world of JavaScript applications, these problems cater to beginners, guiding them through the foundational aspects of programming in this versatile language. Below table showcases the basic programming problems in Javascript :
Hello World | Write a program that prints “Hello, World!” to the console. |
Variables and Data Types | Create variables of different data types (numbers, strings, booleans) and perform basic operations on them. |
Conditional Statements | Use if, else if, and else statements to implement basic conditional logic. |
Loops | Implement loops (for, while) to iterate through arrays, perform a certain action, or solve iterative problems. |
Arrays | Manipulate arrays: create, access, modify, and iterate through elements. |
Functions | Define and call functions with parameters and return values. |
Error Handling | Use try, catch, and finally blocks to handle exceptions and errors gracefully. |
Callbacks and Asynchronous Programming | Understand and implement callbacks, handle asynchronous operations using callbacks. |
Promises | Use promises to handle asynchronous operations and manage asynchronous code more effectively. |
JSON | Parse and stringify JSON data. |
DOM Manipulation | Interact with the Document Object Model (DOM) to dynamically update HTML and respond to user events. |
Event Handling | Handle browser events such as click, submit, etc., using event listeners. |
AJAX and Fetch API | Make asynchronous HTTP requests using the Fetch API or XMLHttpRequest. |
Local Storage and Cookies | Store and retrieve data locally using local storage and cookies. |
Basic Algorithms | Implement basic algorithms such as sorting (e.g., bubble sort) and searching (e.g., linear search). |
Recursion | Solve problems using recursive functions. |
Object-Oriented Programming (OOP) | Create objects, classes, and methods; implement inheritance and encapsulation. |
ES6 Features | Use ES6 features such as arrow functions, destructuring, template literals, and the let/const keywords. |
Promises and Async/Await | Refactor asynchronous code using promises and the async/await syntax. |
Embark on a transformative learning experience with our comprehensive course, “Building MicroServices in Java for Cloud .”
Key Highlights
Here are 10 basic programming problems along with their solutions:
Problem: Write a program that prints “Hello, World!” to the console.
Solution (Python):
print(“Hello, World!”)
Problem: Write a program that inputs two numbers and prints their sum.
Solution (Java):
import java.util.Scanner;
public class SumOfTwoNumbers {
Scanner scanner = new Scanner(System.in);
System.out.print(“Enter first number: “);
int num1 = scanner.nextInt();
System.out.print(“Enter second number: “);
int num2 = scanner.nextInt();
int sum = num1 + num2;
Problem: Write a program to calculate the factorial of a given number.
Solution (C++):
#include <iostream>
using namespace std;
int factorial(int n) {
if (n == 0 || n == 1)
return 1;
return n * factorial(n – 1);
int main() {
int num;
cout << “Enter a number: “;
cin >> num;
cout << “Factorial: ” << factorial(num) << endl;
return 0;
Problem: Write a program that checks if a given number is even or odd.
Solution (JavaScript):
let number = 7;
if (number % 2 === 0) {
console.log(number + ” is even”);
console.log(number + ” is odd”);
Problem: Write a program to reverse a given string.
original_string = “Hello, World!”
reversed_string = original_string[::-1]
print(“Reversed String:”, reversed_string)
Problem: Generate the Fibonacci series up to a specific limit.
public class FibonacciSeries {
int limit = 10;
int firstTerm = 0, secondTerm = 1;
System.out.println(“Fibonacci Series up to ” + limit + ” terms:”);
for (int i = 1; i <= limit; ++i) {
System.out.print(firstTerm + “, “);
int nextTerm = firstTerm + secondTerm;
firstTerm = secondTerm;
secondTerm = nextTerm;
Problem: Write a program to check if a given number is prime.
def is_prime(number):
if number > 1:
for i in range(2, int(number / 2) + 1):
if (number % i) == 0:
return False
else:
return True
return False
if is_prime(num):
print(num, “is a prime number.”)
print(num, “is not a prime number.”)
Problem: Write a program to find the maximum element in an array.
int findMax(int arr[], int size) {
int max = arr[0];
for (int i = 1; i < size; ++i) {
if (arr[i] > max) {
max = arr[i];
return max;
int numbers[] = {5, 8, 2, 10, 3};
int size = sizeof(numbers) / sizeof(numbers[0]);
cout << “Maximum Element: ” << findMax(numbers, size) << endl;
Problem: Write a program to check if a given string is a palindrome.
public class PalindromeCheck {
String str = “level”;
String reversedStr = new StringBuilder(str).reverse().toString();
if (str.equals(reversedStr)) {
System.out.println(str + ” is a palindrome.”);
System.out.println(str + ” is not a palindrome.”);
Problem: Write a program to count the number of vowels and consonants in a given string.
text = “Hello, World!”
vowels = “AEIOU
Solving basic programming problems offers numerous benefits for individuals looking to enhance their programming skills. Here are some key advantages:
Skill Development:
Logical Thinking:
Learning New Concepts:
Preparation for Interviews:
Building a Portfolio:
Enhanced Efficiency:
Community Engagement:
Career Advancement:
Personal Satisfaction:
In summary, regular practice of solving basic programming problems contributes significantly to skill development, logical thinking, and overall proficiency in the field of programming.
For Latest Tech Related Information, Join Our Official Free Telegram Group : PW Skills Telegram Group
Web development refers to the process of creating and maintaining websites, including the design, functionality, and content.
Bootstrap icons can be easily customized using CSS, allowing you to adjust properties such as color, size, and stroke to…
Basic HTML tags are super important in building blocks of the web page framework. Read this article to know more…
Your email address will not be published. Required fields are marked *
Save my name, email, and website in this browser for the next time I comment.
Java stdin and stdout i easy java (basic) max score: 5 success rate: 96.83%, java if-else easy java (basic) max score: 10 success rate: 91.38%, java stdin and stdout ii easy java (basic) max score: 10 success rate: 92.78%, java output formatting easy java (basic) max score: 10 success rate: 96.54%, java loops i easy java (basic) max score: 10 success rate: 97.66%, java loops ii easy java (basic) max score: 10 success rate: 97.32%, java datatypes easy java (basic) max score: 10 success rate: 93.70%, java end-of-file easy java (basic) max score: 10 success rate: 97.91%, java static initializer block easy java (basic) max score: 10 success rate: 96.12%, cookie support is required to access hackerrank.
Seems like cookies are disabled on this browser, please enable them to open this website
Download the free Kindle app and start reading Kindle books instantly on your smartphone, tablet, or computer - no Kindle device required .
Read instantly on your browser with Kindle for Web.
Using your mobile phone camera - scan the code below and download the Kindle app.
MATLAB: A Practical Introduction to Programming and Problem Solving , winner of TAA’s 2017 Textbook Excellence Award ("Texty"), guides the reader through both programming and built-in functions to easily exploit MATLAB's extensive capabilities for tackling engineering and scientific problems. Assuming no knowledge of programming, this book starts with programming concepts, such as variables, assignments, and selection statements, moves on to loops, and then solves problems using both the programming concept and the power of MATLAB. The fifth edition has been updated to reflect the functionality of the current version of MATLAB (R2018a), including the addition of local functions in scripts, the new string type, coverage of recently introduced functions to import data from web sites, and updates to the Live Editor and App Designer.
About the author, product details.
Stormy attaway.
Discover more of the author’s books, see similar authors, read author blogs and more
Customer Reviews, including Product Star Ratings help customers to learn more about the product and decide whether it is the right product for them.
To calculate the overall star rating and percentage breakdown by star, we don’t use a simple average. Instead, our system considers things like how recent a review is and if the reviewer bought the item on Amazon. It also analyzed reviews to verify trustworthiness.
There was a problem filtering reviews right now. please try again later..
Join the community, edit social preview.
Remove a code repository from this paper, mark the official implementation from paper authors, add a new evaluation result row.
TASK | DATASET | MODEL | METRIC NAME | METRIC VALUE | GLOBAL RANK | REMOVE |
---|
Add a method, remove a method, edit datasets, an efficient integer programming model for solving the master planning problem of container vessel stowage.
15 Aug 2024 · Jaike van Twiller , Agnieszka Sivertsen , Rune M. Jensen , Kent H. Andersen · Edit social preview
A crucial role of container shipping is maximizing container uptake onto vessels, optimizing the efficiency of a fundamental part of the global supply chain. In practice, liner shipping companies include block stowage patterns that ensure that containers in above and below deck partitions of bays have the same destination. Despite preventing restows, increasing free space, and benefits for crane makespan and hydrostatics, this practical planning requirement is rarely included in stowage optimization models. In our paper, we introduce a novel 0-1 IP model that searches in the space of valid paired block stowage patterns, named template planning, which ensures sufficient vessel capacity and limits to crane makespan, trim, and bending moment. Our results show that template planning outperforms traditional allocation planning concerning optimality and runtime efficiency while preserving a sufficiently accurate representation of master planning constraints and objectives.
IMAGES
VIDEO
COMMENTS
Learn a time-tested method for solving coding problems from the book How to Solve It by George Pólya. Follow the steps of understanding the problem, devising a plan, carrying out the plan, and looking back.
LeetCode provides a collection of problems for various topics and difficulty levels to help you prepare for coding interviews. You can filter by status, tags, difficulty, frequency, and company, and see the acceptance rate and solution of each problem.
Learn how to solve coding challenges online and improve your problem solving skills with these 10 popular websites. Compare features, languages, difficulty levels, and examples of each website.
Write queries in MySQL syntax. 80 Problems. Intermediate level. Practice over 5000+ problems in coding languages like Python, Java, JavaScript, C++, SQL and HTML. Start with beginner friendly challenges and solve hard problems as you become better. Use these practice problems and challenges to prove your coding skills.
Learn how to break down complex problems into sub-problems, plan your solution, and debug your code. Follow the steps and examples from experts and improve your problem-solving skills.
Learn programming by solving a variety of basic problems that cover fundamental concepts and techniques. This guide provides practice, explanations, and benefits of mastering the basics for aspiring coders.
Learn how to solve programming problems using a powerful process called the Seven Steps. This course covers algorithms, programming language concepts, and C programming details.
Learn how to program and solve problems with this comprehensive guide. Find out what is programming, how to choose your first language, how to set up your development environment, and how to avoid common mistakes.
Code challenges help you improve your problem-solving skills, learn new languages and algorithms, and prepare for coding interviews. Find out how to choose the right challenge for your level and practice with examples of web development, data analysis, and more.
Learn how to solve problems in programming by following the three steps: understand, plan and divide. See examples of pseudocode, decomposition and Fizz Buzz exercise.
HackerEarth helps you hire and upskill developers based on skills, not resumes. Learn how to create coding tests, interviews, and hackathons with data-driven insights and AI-powered evaluation.
Learn how to develop and improve problem solving skills in programming with this ultimate guide. Find out the steps involved, the impact on your career, and the tips to improve your skills.
Computational Thinking is the thought processes involved in understanding a problem and expressing its solution in a way that a computer can effectively carry out. Computational thinking involves solving problems, designing systems, and understanding human behavior (e.g. what the user needs or wants) - thinking like an engineer. Computational ...
Basic Programming Problems: Engaging in code challenges offers many benefits, serving as a dynamic tool to enhance problem-solving proficiency, deepen your comprehension of the programming language you work with, and acquaint yourself with diverse algorithms. If you aspire to elevate your programming skills, immersing yourself in coding is the most effective avenue.
Welcome to Programming Problems! Join us as we explore the exciting world of problem-solving and competitive programming. From data structures to algorithms, we provide tutorials, examples, and ...
Problem-solving skills are almost unanimously the most important qualification that employers look for….more than programming languages proficiency, debugging, and system design.
Solve Problem. Platform to practice programming problems. Solve company interview questions and improve your coding intellect.
functional_programming. math. numbers. Very Easy. Add to bookmarks. Add to collection. Basketball Points. You are counting points for a basketball game, given the amount of 2-pointers scored and 3-pointers scored, find the final points for the team and return that value. Examples points(1, 1) 5 points(7, 5) 29 points(38, 8) 100 Notes N/A
Either way is fine as long as you are writing it out line-by-line and understand the logic on each line. Refer back to the problem to make sure you are on track. 5. Translate pseudocode into code and debug. When you have your pseudocode ready, translate each line into real code in the language you are working on.
Join over 23 million developers in solving code challenges on HackerRank, one of the best ways to prepare for programming interviews.
Interactive debugging. Log-file analysis. Unit and integration test. Analyze the bundle file if the problem is related to the web performance. 3. Use Spectrum Thinking Instead of Binary Thinking. Binary thinking is always putting things in terms of two alternatives that are usually mutually exclusive.
In summary, here are 10 of our most popular problem solving courses. Effective Problem-Solving and Decision-Making: University of California, Irvine. Creative Thinking: Techniques and Tools for Success: Imperial College London. Solving Complex Problems: Macquarie University. Solving Problems with Creative and Critical Thinking: IBM.
MATLAB: A Practical Introduction to Programming and Problem Solving, winner of TAA's 2017 Textbook Excellence Award ("Texty"), guides the reader through both programming and built-in functions to easily exploit MATLAB's extensive capabilities for tackling engineering and scientific problems.Assuming no knowledge of programming, this book starts with programming concepts, such as variables ...
How Edabit Works. This is an introduction to how challenges on Edabit work. In the Code tab above you'll see a starter function that looks like this: public static boolean returnTrue () { } All you have to do is type return true; between the curly braces { } and then click the Check button. If you did this correctly, the button will turn re ...
Upload an image to customize your repository's social media preview. Images should be at least 640×320px (1280×640px for best display).