Improvise the code against test cases where code fails

I wrote below code and i want to identify the test cases where my code fails.I recently participated in contest where my one test case is failed to pass out of 15 test cases, I have one more attempt left and I want to identify the possible test cases where my test case failed. so i will improvise the same, in addition I also want to enhance it, meaning,also suggest me the best practice to improve performance.

At last, In the below code I have one method returnFinalComplement(String reverseStr) which return the complement, for calculating complement I have two Approaches, both are doing the same job, I am currenlty using approach-1, but i want to know about approach-2, which approach can pass all the test cases .

import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; import java.util.Objects; import java.util.SortedSet; import java.util.TreeSet;  /*  * To change this license header, choose License Headers in Project Properties.  * To change this template file, choose Tools | Templates  * and open the template in the editor.  */ /**  *  * @author Ossu  */ class DNAString {      private final static Character[] DATASET = {'A', 'C', 'G', 'T'};     private final static int MIN_RANGE = 0;     private final static int MAX_RANGE = 1000;     private final static String INVALID_CHAR = "Invalid input,not matched with dataset";     private final static String CHAR_LENGTH_EXCEEDS = "Input does not allow to be exceeds more than " + MAX_RANGE + " characters";      private static String returnFinalComplement(String reverseStr) { //APPROACH-1         StringBuilder finalStr = new StringBuilder();         for (char c : reverseStr.toCharArray()) {             finalStr.append(                     c == 'G' ? 'C'                             : c == 'C' ? 'G'                                     : c == 'T' ? 'A'                                             : c == 'A' ? 'T'                                                     : c             );          }         return finalStr.toString();   //APPROACH-2   char[] charlist = list.toCharArray();         for (int i = 0; i < charlist.length; i++) {             switch (charlist[i]) {                 case 'A': {                     charlist[i] = 'T';                 }                 break;                 case 'T': {                     charlist[i] = 'A';                 }                 break;                 case 'G': {                     charlist[i] = 'C';                 }                 break;                 case 'C': {                     charlist[i] = 'G';                 }                 break;             }         }         return new String(charlist);        }       public static boolean validateInput(String input) {         List<Character> chars = new ArrayList<>();         for (char c : input.toCharArray()) {             chars.add(c);         }         boolean result = false;         SortedSet<Character> mySet = new TreeSet<>(chars);         for (int i = 0; i <= mySet.size();) {             for (Character c : mySet) {                 result = Objects.equals(c, DATASET[i]);                 i++;                 if (!result) {                     break;                 }             }             if (result) {                 return result;             } else {                 break;             }         }         return result;      }      public static String reverseIt(String source) {         int i, len = source.length();         StringBuilder dest = new StringBuilder(len);         for (i = (len - 1); i >= 0; i--) {             dest.append(source.charAt(i));         }         return dest.toString();     }      public static void main(String[] args) throws IOException {          BufferedReader readInput = new BufferedReader(new InputStreamReader(System.in));         String source = readInput.readLine();         if (source.length() > MIN_RANGE && source.length() <= MAX_RANGE) {             boolean validateInput = validateInput(source);             if (validateInput) { //                String reverseString = reverseIt(source);                 String reverseString = reverseIt(source);                 System.out.println(returnFinalComplement(reverseString)); //                String revereStringComplement = returnFinalComplement(reverseString);             } else {                 System.out.println(INVALID_CHAR);             }         } else {             System.out.println(CHAR_LENGTH_EXCEEDS);         }     } } 

initramfs fails to find root filesystem on recently updated system

On a recent installation of Ubuntu 18.04, the system has installed fine. However attempting to upgrade the systems kernel from kernel image 4.15.0-29-generic to 4.15.0-43-generic the kernel would panic due to no found root filesystem.

[   0.327121] md: Waiting for all devices to be available before autodetect [   0.327823] md: If you don't use raid, use raid=noautodetect [   0.328622] md: Autotecting RAID arrays. [   0.629322] md: autorun ... [   0.330013] md: ... autorun DONE. [   0.330722] VFS: Cannot open root device "UUID=<UUID>" or unknown-block(0,0): error -6 [   0.331434] Please append a correct "root=" boot option; here are the available partitions: [   0.332162] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0) [   0.332878] CPU: 2 PID: 1 Comm: swapper/0 Not tained 4.15.0-43-generic #46-Ubuntu [   0.333599] Hardware name: To Be Filled By O.E.M. To Be Filled By O.E.M./X99 Extreme4, BIOS P2.00 06/01/2015 <KERNEL CALL TRACE> 

As you can see when attempting to load the filesystem from within the current initramfs (4.15.0-43-generic) no disks are detected. Switching back to the previous initramfs (4.15.0-29-generic) still allowed the root filesystem to be detected and loaded.

At a later point (several updates) even the 4.15.0-29-generic initramfs failed to find the root filesystem.

As of right now I have checked all disks to SMART, flashed the motherboard with an updated UEFI firmware, and performed multiple fscks against the filesystem. At this point the GPT layout looks fine, there are no filesystem errors, and SMART has come back with no disk faults or errors.

The only way I have found to continue booting the system is to pull the initramfs modules from the Ubuntu 18.04 Live CD and rebuilt the original initramfs for 4.15.0-29-generic. This process has at least been met with limited success in that I can once again boot the system albeit without any extra modules such as the nvidia display drivers.

Any suggestions would be appreciated.

Git completion fails after updating to Ubuntu 18.10 Cosmic Cuttlefish

I recently updated to Ubuntu 18.10 and after that my git completion has been failing.

Bash is able to complete the first command successfully, for example (I’ll use ↬ to indicate TAB was used)

$   ala↬ $   alacritty 

But when I use tab to complete a git command it fails.

$   git stat↬ $   git status #should be $   git statunknown option: --list-cmds=list-mainporcelain,others,nohelpers,alias,list-complete,config usage: git [--version] [--help] [-C <path>] [-c <name>=<value>]        [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]        [-p | --paginate | --no-pager] [--no-replace-objects] [--bare]        [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]        <command> [<args>] 

I’ve tried reinstalling bash-completion

$   sudo apt install --reinstall bash-completion  

Check if it was some issue in my ~/.bashrc Link

Do you have an idea how to fix this?

Example of a polynomial that fails to be non-zero over a higher field than $\mathbb{C}$ or $\mathbb{R}$?

It’s well known over the field $ \mathbb{F}_2 $ that the polynomial $ p(x) = x^2 – x$ is equivalent to the $ 0$ polynomial over the field. Naturally however if we consider say $ \mathbb{R}$ then it’s easy to see that $ x^2 -x$ is not $ 0$ everywhere.

This leads to an interesting question: are there examples of (possibly multivariate) polynomial expressions $ P(x_0,x_1…x_k)$ such that $ P$ is $ 0$ everywhere over $ \mathbb{C}$ or $ \mathbb{R}$ but such that there is a field $ K$ of which $ \mathbb{C}$ or $ \mathbb{R}$ is a quotient field (or sub-field), and the specific polynomial $ P$ is not identically $ 0$ over the entirety of $ K$ .

I am trying to move a file from sdcard to another device folder and it fails with error that file is not there, but it is!

I am trying to move a file from /sdcard to another device file and I am getting the following:

mv: bad 'xxxxxxxx.0': No such file or directory

while ls -l shows the file in directory.

The device is physical one, not an emulator and it is rooted. Why is this happening? file confirms this is an ASCII file. I know cases that this was happening when someone was trying to move 32bit binary to 64bit device, but this is just an ASCII text file.

Perf build in Ubuntu 18.10 fails

I upgraded my Ubuntu installation to 18.10. The kernel I am using is “4.18.0-13-lowlatency”.

I have installed perf using linux-tools-common package. Perf works but I can’t use the python/perl scripting abilities.

Python scripting not supported. Install libpython and rebuild perf to enable it. For example: # apt-get install python-dev (ubuntu) # yum install python-devel (Fedora) etc.

I followed the steps here, cloned the corresponding release of Ubuntu-Cosmic. But when I try to build perf, I get following error:

util/parse-events.c: In function ‘parse_events__scanner’: util/parse-events.c:1795:8: error: implicit declaration of function ‘parse_events_lex_init_extra’; did you mean ‘parse_events_set_extra’? [-Werror=implicit-function-declaration] ret = parse_events_lex_init_extra(start_token, &scanner); ^~~~~~~~~~~~~~~~~~~~~~~~~~~ parse_events_set_extra util/parse-events.c:1795:8: error: nested extern declaration of ‘parse_events_lex_init_extra’ [-Werror=nested-externs]

Any hints on how to solve this problem?

Why my python code fails due to time limit exceeded? (Kattis prime reduction challenge)

I am solving the prime reduction challenge on Kattis (https://open.kattis.com/problems/primereduction). I’m already solve it using Java. Now I am trying to solve it on python. My code did well on the sample tests, but on the second test my code fails because time limit exceeded.

Someone could tell me what I did wrong?

My python code:

    import sys from math import sqrt, floor  def is_prime_number(number):     if number == 2:         return True     if number % 2 == 0:         return False     return not any(number % divisor == 0 for divisor in range(3, floor(sqrt(number)) + 1, 2))  def sum_prime_factors(number):     factors = 0     while number % 2 == 0:         factors += 2         number = floor(number / 2)     if is_prime_number(number):         factors += number         return factors     for factor in range(3, floor(sqrt(number)) + 1, 2):         if is_prime_number(factor):             while number % factor == 0:                 factors += factor                 number = number / factor             if number == 1:                 return factors      factors += number     return factors  def print_output(x, i):     if is_prime_number(x):         print(x, i)         return     i = i + 1     factors = sum_prime_factors(x)     print_output(factors, i )  [print_output(item, 1) for item in map(int, sys.stdin) if item != 4] 

Lineageos + opengapps: remove gapps, dirty migration to lineageos-for-microg fails

I’ve got a motorola g4. Bootloader unlocked, twrp installed, lineageos installed, opengapps installed, non-rooted. Been using it for about a year.

I want to try lineageos-for-microg: https://lineage.microg.org/

I want to keep my current data/apps (including some enduser google apps like their pdf viewer) as much as possible and migrate to microg, removing only the “core” google stuff a user doesn’t generally care about directly that will be replaced by microg. So, I’m following the dirty install process.

I have none of the listed apps installed.

I have tried removing opengapps, but it doesn’t seem to work. Using the aroma installer to choose settings until the config at the end is “Include” with no apps listed, some google apps are still installed (notably, the play store) after rebooting. The opengapps installer process also mentions removing existing/obsolete apps for only a short time, then moves to the next step “installing gapps” which takes a long time. This seems to contradict the settings I gave it, namely to leave none installed, but is consistent with the fact that they don’t seem to get uninstalled.

I have also flashed https://github.com/CHEF-KOCH/Remove-Gapps to try to get rid of them but some gapps (like the play store) still survive.

After any combination of attempts to follow the instructions and remove the gapps, I flash the key migration zip followed by the lineage-microg zip for my device (athene). I also make sure to wipe the dalvik and cache partitions before rebooting.

After all this, every time I reboot, my system is almost exactly like it was before I did anything: google services installed (though the play store does not actually work, it’s still there), the microg settings app is not installed, etc. A few things are broken (some notifications of apps crashing) but overall nothing noteworthy has happened.

I’ve resorted to even wiping /system before a migration attempt, but even this achieves nothing.

I got a partial success once by manually going through /system/app, /system/priv-app, and /data/app and removing anything that looked google-y, then performing the migration. Upon rebooting, the microg settings app was present and the self-check section looked like it should look on a clean install, but the play store was still present. I don’t know to what extent this migration was a success.

I’m not familiar with the android/google ecosystem’s insides and app politics, just the userland, so when I’m manually going around deleting files I have little knowledge of what I’m doing, so I don’t consider this attempt a success.

Now that all the info has been laid out, could someone please help me cleanly perform the migration to lineage-microg, without excessive butchering of my system or leaving things that should not be left? Why does the dirty install procedure laid out by the lineage-microg team fail? Why do the gapps removal tools fail? What exactly is necessary to correctly and cleanly migrate lineage to lineage-microg?