Programming & Computer Science Answers

C++ 9913
Python 5288
Java | JSP | JSF 3611
C 1680
C# 1362
Computer Networks 989
Algorithms 652
Databases | SQL | Oracle | MS Access 641
HTML/JavaScript Web Application 588
Other 537
Visual Basic 358
Assembler 209
Software Engineering 202
AJAX | JavaScript | HTML | PHP 166
MatLAB 150
MatLAB | Mathematica | MathCAD | Maple 124
Action Script | Flash | Flex | ColdFusion 112
UNIX/Linux Programming 89
Web Development 73
Excel 36
ASP | ASP.NET 23
Delphi | Pascal 21
Perl 16
Prolog 9
Functional Programming 9
MathCAD 5
Wolfram Mathematica 4
WPF 4
Ruby | Ruby on Rails 3
NodeJS Web Application 2

Questions answered by Experts: 26 876

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search

heck values in the Array is a String

Given an array

myArray, write a Python program to check whether each value of the array is a string or not .


Input:

  • The input will be a single line containing an array myArray

Output

  • The output should be a single line containing a boolean value


input:

["apple","goa","hyderabad"]

output:

true


input:

["dog","fox","70","movie"]

output:

false





write a code in VB which will input the details in 3 parallel arrays (Item_name, quantity, price). Print the list of 5 items purchased in order of costliest to cheapest


Split and Replace


Given three strings


inputString, separator and replaceString as inputs. Write a Python program to split the

inputString with the given separator and replace strings in the resultant array with the replaceString whose length is greater than 7.


input:

Javascript-is-amazing

-

programming



output:

programming is amazing



input:

the&lion&king

&

tiger



output:

the lion king



Square at Alternate Indices

Given an array

myArray of numbers, write a function to square the alternate numbers of the myArray, starting from index 0.Input

  • The input will be a single line containing an array myArray

Output

  • The output should be a single line containing an array with alternate numbers squared

Constraints

  • Each value in the array must be a number

input:

[1,2,3,4,5]

output:

[1,2,9,4,25]


input:

[2,4]

output:

[4,4]



Consider the 2021 puzzle, which is a lot like the 15-puzzle we talked about in class, but: (1) it’s played on a 4x5 board, (2) it has 20 tiles, so that there are no empty spaces on the board, (3) instead of moving a single tile into an open space, a move in this puzzle consists of either (a) sliding an entire row of tiles left or right, with the left- or right-most tile “wrapping around” to the other side of the board, or (b) sliding an entire column of the puzzle up or down, with the top- or bottom-most tile “wrapping around.” However, each given row or column can only be slid in a certain way: the first and third rows can only be slid left; the second and fourth rows can only be slid right; the first, third, and fifth columns can only be slid up; and the second and fourth columns can only be slid down. For example, here is a sequence of two moves on such a puzzle: 2 1 2 3 4 5 1 2 3 4 5 1 17 3 4 5 6 7 8 9 10 → 10 6 7 8 9 → 10 2 7 8 9 11 12 13 14 15 11 12 13 14 15 11 6 13 14 15 16 17 18 19 20 16 17 18 19 20 16 12 18 19 20 The goal of the puzzle is to find a short sequence of moves that restores the canonical configuration (on the left above) given an initial board configuration. We’ve provided skeleton code to get you started. You can run the skeleton code on the command line: python3 solver2021.py [input-board-filename] where input-board-filename is a text file containing a board configuration (we have provided an example). You’ll need to complete the function called solve(), which should return a list of valid moves, each of which is encoded as a letter L, R, U, or D for left, right, up, or down, respectively, and a row or column number (indexed beginning at 1). (For instance, the moves in the picture above would be R2 D2.) The initial code does not work correctly. Using this code as a starting point, implement a fast version, using A* search with a suitable heuristic function that guarantees finding a solution in as few moves as possible. Try to make your code as fast as possible even for difficult boards, although it is not necessarily possible to write code that will be able to quickly solve all puzzles. In addition to doing your own testing, it is important that you test your program on the SICE Linux servers to ensure that we will be able to run it and grade it accurately


Given an integer N, write a program to print the sandglass star pattern, similar to the pattern shown below.
* * * * * 
 * * * * 
  * * * 
   * * 
    * 
   * * 
  * * * 
 * * * * 
* * * * * 

Input

The input will be a single line containing a positive integer (N).
Output

The output should contain the asterisk(*) characters in the sandglass star pattern.
Note: There is a space after each asterisk(*) character.
Explanation

For example, if the given number is 5, the pattern should contain 9 rows and 9 columns as shown below.
* * * * * 
 * * * * 
  * * * 
   * * 
    * 
   * * 
  * * * 
 * * * * 
* * * * * 

Sample Input 1
5
Sample Output 1
* * * * * 
 * * * * 
  * * * 
   * * 
    * 
   * * 
  * * * 
 * * * * 
* * * * * 

Sample Input 2
3
Sample Output 2
* * * 
 * * 
  * 
 * * 
* * * 
Given the number of rows N, write a program to print the hallow diamond pattern similar to the pattern shown below.
    A
   B B
  C   C
 D     D
E       E
 D     D
  C   C
   B B
    A

The input will be a single line containing a positive integer (N).
Output

The output should be (2*N - 1) rows and (2*N - 1) columns containing the alphabet characters in the hollow diamond pattern.
Explanation

For example, if the given number is 5, the pattern should contain 9 rows and 9 columns as shown below.
    A
   B B
  C   C
 D     D
E       E
 D     D
  C   C
   B B
    A

Sample Input 1
5
Sample Output 1
    A
   B B
  C   C
 D     D
E       E
 D     D
  C   C
   B B
    A

Sample Input 2
3
Sample Output 2
  A
 B B
C   C
 B B
  A
Given a string in camel case, write a python program to convert the given string from camel case to snake case.
Input

The input will be a single line contain a string.
Output

The output should contain the given word in snake case.
Explanation

For example, if the given word is "PythonLearning" in camel case, your code should print given word in snake case "python_learning".
Sample Input 1
PythonLearning
Sample Output 1
python_learning

Sample Input 2
CamelCase
Sample Output 2
camel_case
Given a number N, write a program to print a triangular pattern of N lines with numbers as shown below.
Input

The input will be a single line containing a positive integer (N).
Output

The output should be N rows with numbers.
Note: There is no space between the numbers.
Explanation

For example, if the given number of rows is 4,
your code should print the following pattern
1
121
12321
1234321

Sample Input 1
4
Sample Output 1
1
121
12321
1234321

Sample Input 2
9
Sample Output 2
1
121
12321
1234321
123454321
12345654321
1234567654321
123456787654321
12345678987654321


Write a program to print the right alphabetic triangle up to the given N rows.
Input

The input will be a single line containing a positive integer (N).
Output

The output should be N rows with letters.
Note: There is a space after each letter.
Explanation

For example, if the given number of rows is 4,
your code should print the following pattern.
A 
A B 
A B C 
A B C D

Sample Input 1
4
Sample Output 1
A 
A B 
A B C 
A B C D 

Sample Input 2
6
Sample Output 2
A 
A B 
A B C 
A B C D 
A B C D E 
A B C D E F 


LATEST TUTORIALS
APPROVED BY CLIENTS