answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
sasho
1 month ago
14

Given a pattern as the first argument and a string of blobs split by | show the number of times the pattern is present in each b

lob and the total number of matches.Input:The input consists of the pattern ("bc" in the example) which is separated by a semicolon followed by a list of blobs ("bcdefbcbebc|abcdebcfgsdf|cbdbesfbcy|1bcdef23423bc32" in the example). Example input: bc;bcdefbcbebc|abcdebcfgsdf|cbdbesfbcy|1bcdef23423bc32Output:The output should consist of the number of occurrences of the pattern per blob (separated by |). Additionally, the final entry should be the summation of all the occurrences (also separated by |). Example output: 3|2|1|2|8 where bc was repeated 3 times, 2 times, 1 time, 2 times in the 4 blobs passed in. And 8 is the summation of all the occurrences. (3+2+1+2 = 8)Test 1:Input: aa;aaaakjlhaa|aaadsaaa|easaaad|saOutput: 4|4|2|0|10Code to be used:import java.io.BufferedReader;import java.io.IOException;import java.io.InputStreamReader;import java.nio.charset.StandardCharsets;public class Main {/** * Iterate through each line of input. */public static void main(String[] args) throws IOException {InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);BufferedReader in = new BufferedReader(reader);String line;while ((line = in.readLine()) != null) {String[] splittedInput = line.split(";");String pattern = splittedInput[0];String blobs = splittedInput[1];Main.doSomething(pattern, blobs);}} public static void doSomething(String pattern, String blobs) {// Write your code here. Feel free to create more methods and/or classes}}
Computers and Technology
1 answer:
Amiraneli [921]1 month ago
5 0

Response:

The code is provided below

Clarification:

import java.io.BufferedReader;

import java.io.IOException;

import java.io.InputStreamReader;

import java.nio.charset.StandardCharsets;

public class Main {

  /**

  *

  * Process each line of input.

  *

  */

  public static void main(String[] args) throws IOException {

      InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);

      BufferedReader in = new BufferedReader(reader);

      String line;

      while ((line = in.readLine())!= null) {

          String[] splittedInput = line.split(";");

          String pattern = splittedInput[0];

          String blobs = splittedInput[1];

          Main.doSomething(pattern, blobs);

      }

  }

  public static void doSomething(String pattern, String blobs) {

      // Implement your code here. You can create more methods or classes if needed

      int total = 0;

      String arrblobs[] = blobs.split("\\|");

      for (int i = 0; i < arrblobs.length; ++i) {

          int count = 0, index = 0;

          for (;;) {

              int position = arrblobs[i].indexOf(pattern, index);

              if (position < 0)

                  break;

              count++;

              index = position + 1;

          }

          System.out.print(count + "|");

         

          total += count;

      }

      System.out.println(total);

  }

}

You might be interested in
Which of the following does not describe local alignment algorithm?
8_murik_8 [892]

Response:

The correct option is "Option a".

Analysis:

A negative score can be harmful. A score below zero indicates that the sequences leading up to this point are uncorrelated, effectively voiding their influence on prior alignment. Thus, alignment can still be pursued at any position later in the calculation. The other options can be elaborated on:[

  • In option b, the score could potentially be negative, hence its value cannot be fixed.
  • Option c states that some value is required in the first row and column, ruling it out as correct.
  • As for option d, it suggests starting with a lower score and concluding with a higher one, which is also incorrect.

8 0
11 days ago
Create a conditional expression that evaluates to string "negative" if user_val is less than 0, and "non-negative" otherwise.
maria [879]

Answer:

The revised code is as follows:

user_val = int(input())

cond_str = 'non-negative'  

if user_val < 0:

   cond_str = 'negative'  

print(user_val, 'is', cond_str)

Explanation:

This retrieves input for user_val

user_val = int(input())

This sets cond_str to 'non-negative'

cond_str = 'non-negative'

In cases where user_val is below 0

if user_val < 0:

Here cond_str changes to 'negative'

   cond_str = 'negative'  

This displays the intended output

print(user_val, 'is', cond_str)

4 0
1 month ago
What happened if the offshore team members are not able to participate in the iterations demo due to timezone/infrastructure iss
zubka84 [945]

What if the offshore team members are unable to join the iterations demonstration because of timezone or infrastructure issues? (c) Not a significant problem. The offshore lead and the onsite team members will attend the demo with the product owner and can relay the feedback to the offshore team afterwards.

Explanation:

Not a significant problem. The offshore lead and the onsite team members will attend the demo with the product owner and can relay the feedback to the offshore team afterwards.

From the previous statement, it is evident that if offshore team members cannot attend the demo alongside the product owner due to issues with time zones or infrastructure, it won't pose a major concern because the onsite team will be present and can share all relevant insights and feedback with the offshore team. They all belong to the same team.

Therefore, the answer (3) is correct

4 0
1 month ago
Which of the following is true of how the Internet has responded to the increasing number of devices now using the network? a) T
Harlamova29_29 [932]

Answer:

A

Explanation:

Every year, internet protocols are adjusted to accommodate the influx of new devices on the network. In the 1990s, traffic primarily utilized a few protocols.  IPv4 managed packet routing, TCP handled those packets to establish connections, SSL (later TLS) secured those connections, DNS resolved hostnames, and HTTP was the main application layer protocol utilized.

For years, there were minimal modifications to the fundamental internet protocols; HTTP saw the addition of some new headers and methods, TLS underwent gradual updates, TCP improved congestion management, and DNS incorporated features like DNSSEC. Over a lengthy period, these protocols remained consistent as seen on the wire — with the exception of IPv6, which is regularly discussed among network operators.

Consequently, network administrators, vendors, and policymakers seeking to understand (and sometimes regulate) the Internet have implemented various practices based on the protocols’ wire ‘footprint’ — whether to troubleshoot issues, enhance service quality, or enforce policies.

Currently, there are considerable changes happening in core internet protocols. Although these updates aim to remain compatible with the wider Internet to ensure adoption, they might disrupt entities that have exploited undocumented features of existing protocols or assumed stability in certain aspects.

8 0
1 month ago
Read 2 more answers
Need 2.5 Code Practice Answers
Natasha_Volkova [897]

Answer:

import random

random.seed(1,10) # Note: seed takes one argument, so this line has an error

a = random.randint(1, 10)

b = random.randint(1, 10)

print("Calculate: " + str(a) + " X " + str(b) + "?")

ans = int(input("Your answer: "))

if ans == a * b:

print("Well done!")

else:

print("That's wrong!")

Explanation:

4 1
1 month ago
Read 2 more answers
Other questions:
  • Implement the function couple, which takes in two lists and returns a list that contains lists with i-th elements of two sequenc
    8·1 answer
  • Splunk In most production environments, _______ will be used as the source of data input?
    12·1 answer
  • Ajay wants to read a brief overview about early settlers in the United States. Which type of online text source should he most l
    9·2 answers
  • Consider the following skeletal C program: void fun1(void); /* prototype */ void fun2(void); /* prototype */ void fun3(void); /*
    11·1 answer
  • How has the development of personal computer hardware and software reversed some of the trends brought on by the industrial revo
    15·1 answer
  • Fill the validateForm function to check that the phone number contains a number (use the isNaN function) and that the user name
    10·1 answer
  • You work for a car rental agency and want to determine what characteristics are shared among your most loyal customers. To do th
    10·1 answer
  • Write a program that prompts the user to enter three cities and displays them in ascending order. Here is a sample run: Enter th
    8·1 answer
  • What term best describes the grammatical rules for writing proper code? paths syntax hyperlinks declarations
    7·2 answers
  • Which of the following is NOT true about data?
    8·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!