instruction
stringlengths
71
71.9k
I am no longer running this server, nor does this question reflect my current political views. I am currently running a small Donald Trump-themed Discord server. Recently, a few members requested that I create a bot for the server, so I obliged and created, this, TrumpBot. It uses the Discord.Net API to interface with ...
I've programmed a few Project Euler problem but they are all separated in different solutions so I decided to group them all together in a nice Windows forms application. Here's how it looks like : You can select any of the available problems from the list check the answer and the execution time. I'm looking primarly ...
Find the substring count from a string without string functions in Java. Given String str = "abcdefghcde"; and String find = "cde";, count occurrences of "cde" in String str. Taking into account overlaps. Example: String str = "cdcdcdc"; and String find = "cdc";, occurrence count is 3 Please give any feedback about ...
I'm trying to increase my hash table size by two if the table is filled more than half of it. I tried to rehash every single element from the old table and put it back to my new table, then assign my old table as the new table again. What do you guys think of my own created function? I'm practicing for my final exam an...
I was creating some solving algorithm and write test for it. this is the tests : @Test public void test1(){ boolean expected = true; int n = 7; DigitIncreasing digitIncreasing = new DigitIncreasing(); assertEquals(expected,digitIncreasing.isDigitIncreasing(n)); } @Test ...
I am working on an implementation of the Needleman-Wunsch sequence alignment algorithm in python, and I've already implemented the one that uses a linear gap penalty equation for scoring, but now I'm trying to write one that uses an affine gap penalty equation. I tried using as a reference the chapter that covers this ...
This is my attempt to solve the percolation problem for the Princeton Algorithm-I course, the problem is well-defined here. My implementation is in C++ not Java and the following procedure is followed: Create an NxN grid using QuickUnion class and keep track of each grid site by labeling it (except the first row that ...
I want to encode unicode codepoints to UTF-8 manually. I wrote the following C# code. I tested it with some cases I know, but I would like to know if it's correct for all inputs. I know that Unicode codepoints are undefined beyond 0x10FFFF ,but I don't care about that. Therefore the output of my method might be more th...
I have an autofiltered table in Excel. I have to copy/paste values based on certain conditions and I also have to perform this on all visible cells in a particular column. I have written the code and it works well but the only thing is that it takes a lot of time as there are many rows. Can anyone please help me how to...
I attempted the Business Rules Kata. Here's a video overview. However, I am not confident that going functional is a good strategy for the following objective: How can you tame these wild business rules? How can you build a system that will be flexible enough to handle both the complexity and the need for change? ...
I need to create this eventEmitter class with the functions listed below. I think I could clean the code a little but don't really know where to start. var eventEmitter =function (){ this.listeners = 0; this.events = {}; return this; }; eventEmitter.prototype.on = function(ev, cb) { if (typeof ev !== 'string...
I have a log file with a million lines, and my task is to code something that outputs the lines that have duplicates, and the line numbers. I've thought of two ways to approach this : 1) Use python's inner tools : load my file's lines in a list, load them in a dict in which the keys are the lines, and the values are...
I'd like to know if the following code is a good implementation of MergeSort? I tried some examples and the code was right, so I guess that the algorithm works correctly. public static int[] myMerge (int[] array, int[] array2){ int[] giveback = new int[array.length + array2.length]; int i = 0; int j = 0; ...
A week ago I did a three function calculator, I took the input from you guys and made it better. Overall it works fine, I didn't find any problems. But as a beginning programer I'd like some input on this calculator. // Three function Calculator.cpp : main project file. #include "stdafx.h" #include<iostream> using std:...
For part of a project, I was given this directive: The grep command will take an exact string and an exact filename as the 2 arguments and you will need to search through the filename for the given string and display the "line" and "line number" the string resides in. Example output would be: # grep bob FileWi...
We have written a Python script using arcpy modules. It is was written by Python beginners and many parts of the code are written in 'unpythonic way'. The goal is to re-write or address 'unpythonic' code. The software used for this script are ArcMap 10.4 and written in Python 2.7. The complete script is available on Gi...
I have built a Vue app which fetches data from an endpoint and presents that data in a table with sortable columns. The app is based on this React challenge which is to create a table of users and their properties, from the data provided in the endpoint. Here are the user stories fulfilled: I can see a table of the F...
Its purpose is to find the longest path in an equally-weighted tree denoted as such: 3 1 2 2 3 The first number denotes both the number of vertices and the number of edges (3 - 1). (defn farthest [edg current-node entry-node len] (let [ farthest-key (atom current-node) farthest-val (atom len) ...
Here is my code for classic merge sort. My question is, each time I create a new list result to merge sub-parts, is there a way to save the space -- not creating a new list result? Besides my above major question, any advice for code improvement, bugs, performance (algorithm time complexity perspective) is highly appre...
My goal was to create a function that could check for duplicates in an array no matter what the data type was, given that the size of the data type was provided. This was done by using the \$\mathcal{O}(n^2)\$ algorithm and casting to char because of its 1 byte property. /** * Returns count of duplicates in an array ...
How can I make this better? import random def roll(): input("Press Enter to roll") dice = random.randint(1, 6) + random.randint(1, 6) print("You rolled a {}" .format(dice)) return dice def checkRoll(dice): if dice == 7 or dice == 11: print("You win") playAgain() elif dice == 2 ...
This code is written to find substring count in a string in Python 3. The original problem description is here. Please suggest better ways of solving this. string =input() substring = input() count = 0 i=0 while(i<(len(string)-len(substring))): if(string.find(substring,i,len(string))>=0): count+=1 i...
RunMyAtm package ATM; import java.util.*; import java.io.*; public class RunMyAtm { int input; static Scanner sc = new Scanner(System.in); Account[] myAccounts = new Account[3]; public static void main(String[] args) { RunMyAtm rma = new RunMyAtm(); rma.preAtmMenu(); } public void preAtmMenu() { ...
Here is my code of serialize and de-serialize a binary tree, looking for advice. One issue in my mind which I cannot resolve is, I am using a global variable index, wondering if more elegant solutions in Python 2.7 -- since in Python there is no solution to pass a reference as Java/C++ did. index = 0 class Node: d...
In this program, there is a code that the user has to try to solve in 10 guesses. If you have any numbers in the right spot, it will tell you how many you have correct and the value of the correct numbers so you can figure it out. I know there has to be a much simpler way to do this, I just can't put one together. I...
I'm currently enrolled in a node.js course. The first app we have done in the course was a terminal notebook. It appends objects to a json-file. Example call on the terminal: node notebook.js add Second "Aenean commodo ligula eget dolor." Example structure json-file: [{ "title": "First", "timestamp": 1481534161237...
The following code snippet is about adding rules that filters Payment Methods listing to customer, for email we provide 4 different types of payment methods, but we do show them depending on some rules. <?php namespace App\Services\Checkout\Module; use App\Services\Checkout\Module\PaymentMethodRules\PaymentMethodRule;...
I have written a solution for the codility task which is Binary Gap. finding the highest gap in Binary. for example 1041 is the input number and convert it to binary the result is 5. here is the code : package codility import( "strconv" ) func Solutions(N int) int{ binary := convertNumberToBinary(N) res...
I wrote a node editor library which can be found here. What can I do to make the code more readable and maintainable? I'd like to stay in plain javascript and keep a single reference to use the library. "use strict"; /************************** * Main object **************************/ var Ned = { create(svg) { ...
I need to implement a hash function for a key of type structure. This structure is as follows: typedef struct hash_key_s { void *k1; char *k2; char *k3; } hash_key_t; My proposed hash function is as follows: unsigned long hash_func (void *key) { hash_key_t *k = (hash_key_t *) key; unsigned long h ...
The code below uses a single command line 'filename' argument to create a batch and python skeleton script file in the cwd. The python file is then automatically opened in IDLE for convenience. As a beginner making a significant amount of python files for worked educational examples this could save me 15 minutes per da...
This is an efficiency question to the following code, written in MS Visual in C#. If any explanation is missing, please let me know and I will add. What this part of the program does is: Button is pushed Motor starts moving (by sending 9-byte array with command) Waiting for Sensor to register a change in value Motor ...
The elements in the matrix are either 'M', 'G', 'P' or '.' and the algorith must write out all possible ways of splitting the matrix so it has equal number of M, G and P on each side. It's a task we've been given to do at home. We also had to use use the matrix as a parameter in the function and use it as a pointer in ...
The following program reads a stream and creates a two dimensional std::vector. I'm trying to find an elegant way to handle the errors and recover from them as much as possible while still reporting the problems encountered. It feels as though my nice clean functions are getting more and more cluttered as I add the er...
This weekend I made an attempt at a generic repository pattern for entity framework in .NET after reading this blog post. I was wondering how it could be better. I specifically have a couple questions. Can I be more "in line" with the typical repository pattern? I feel like I lost the typical pattern at some point and...
This is jQuery code which works like this: depending on a user choice it changes the color and background of some elements in the DOM. The behavior is ok, is doing exactly what I want. And as you may see, there is some code repeated. What's the best way to keep a good performance by doing a function in order to avoid r...
I've written a simple application that captures frames from my webcam and streams the frames via a websocket. The stream implementation I've come up with feels weird. Networking is not my strong suit. I am wondering if the communication between the server and app can be written better. type Stream struct { Frame []...
Given a non-negative number represented as an array of digits, plus one to the number. The digits are stored such that the most significant digit is at the head of the list. Explanation for using array vs ArrayList: I could have used ArrayList and that would have been simpler while appending a 1 at the beginning b...
For part of a project, I was given this directive: The find command will use the directory (dirent) function calls, but will require you to start at a directory and then determine if a file is a directory or a file and if it is a directory you will need to walk down that directory as well. You will need a method...
This is improved code after I some issue in pointed by @Edward in the last question: C++ operator overloading for matrix operations This work assignment in operator overloading .I need to use operators *, [][], =, +, -, << on objects of type matrix for example add to matrix using this code: m=m+s. I already sent the...
It's a few weeks old homework, and it's already graded. How can I improve my code? Write function empty(n), which gets the board size as an argument, and returns an empty board with the given size. For instance, empty(4) must return ['', '', '', '']. Write function isEmpty(board) returns True if the given board is emp...
I have a need to drop quantities of elements from an iterator beyond Int.MaxValue so I wrote a helper function that does just that. However, I can't help but feel like I'm doing this the dumb way - that there's got to be some built-in language construct or at least a more elegant way of tackling the problem. /** * dro...
I created a SafeQueue class, which stores pointers. It has two methods: push: Adds a new pointer to the queue next: If the queue is empty, returns nullptr. Otherwise it returns the front element, and pop the queue Most of the time, I have one producer and one consumer. But there may be more. The producer just simply ...
At school, we have a competition where the winner is determined by the length of their unbroken sequence of expressions that evaluate to integers 0 to n. You must use the next year's number in the correct order, every digit exactly once. example: 0 = 2*0*17 1 = 2-01^7 2 = 2-0*17 ... The competition doesn't h...
The system is meant to replicate the deformers and modifiers commonly used in 3D modeling programs like 3DS Max, Maya, Blender and Cinema 4D. I made a post on Reddit, explaining the features and limitations. If you (understandably) don't want to look through all the code, I'll list the important base classes. I'm looki...
I'm trying to learn C++ having come from a C/Assembly background. I thought one of the first tools I'd make as a project is a "directory tally" program: It will count all the files in the current directory If the user specifies, it will count all the folders in the current directory too If the user specifies, it wil...
I've been studying data structures and making implementations for different types. This is my linked list code. Please let me know if there's anything here that could be improved upon or changed for better performance. I should mention that it compiles and functions as intended. Also, I'm not sure what I need the frien...
I just read this post on how to avoid memory leaks with AsyncTask. The post proposed using a WeakReference and supplying a TextView as the object of the WeakReference. In my code, I need to supply multiple parameters to the AsyncTask (not just one as shown in the post). So what I did was create an inner class with the ...
I'm just starting out in MIPS (as is evident by the fact that I'm writing a FizzBuzz program), and my program runs fine and gives the desired output, but I feel like there is a way to do it without as many branches. .data fstring: .asciiz "Fizz\n" bstring: .asciiz "Buzz\n" hstring: .asciiz...
Can someone please review my code? I'm saving a hotel rate to a database. I want to save the rate twice, one field will update with every new rate, and one field will contain the rate that was found for that date the first time it was captured. The code looks very clunky and I know it can be improved. def save_result...
I am working on a sticky element that on certain point when the user scrolls down it turns into a relative element so it's not a sticky element anymore, only when the user scrolls to the top and passes over an specific element it turns again into a fixed/sticky element. function Sticky($el){ this.$el = $el; thi...
I wrote a Pandoc filter that allows me to embed arbitrary HTML snippets in LaTeX documents, which are then printed out as-is when the document is converted to HTML. It is slightly more generic than it needs to be right now, in case I want to embed other types of things in the future. It can be used like: \begin{verbati...
This is an implementation of ntohl() that I wrote as an exercise. ntohl() takes a uint32_t value and returns it unchanged if the host architecture is network-byte-order (big-endian), otherwise the value is converted to host-byte-order. My version converts to little-endian; is it always the case that host-byte-order is ...
I'm working on a small RestApi that would be able to: Interpret different query languages like (...)/countries?where="..."&select="..." or (...)/GetCountries?ids="1,2,3" Translate theses queries to SQL Pass the SQL command to dapper and return the result Note this API will be used by other services and that it won't...
(Initial discussion from Classic merge sort, since it is new code, I start a new thread) Post my code below, my major question is, I have to create another array result to hold sub-parts merge sort result. Is there a way I can just use original number to save additional space in result? Any other comments on code bugs,...
I'm creating a responsive page with bootstrap. I tested my code with my browser (Firefox and Chrome) and it works. Is the code clean or is there a better way to code it? <div class="col-xs-12 col-sm-6 col-md-4" style="margin-top: 2%;"> <div class="adress"> <ul style="list-style: none; padding-left: 0"> ...
Given a serialized hash of any depth in string format, convert it into a hash object. I want to know if my approach is correct, I am capturing states and storing the results in a stack and generating the hash from the stack. Also, is there a name for this kind of parsing approach? def deserialize(input) h = {} l ...
I've written a TicTacToe game using classes, just for learning purposes... and I wonder If this code can be improved. main.cpp #include <iostream> #include "tictactoe.hpp" using namespace std; int main(){ Tictactoe game; game.intro(); return 0; } tictactoe.hpp #ifndef tictactoe_hpp #define tictactoe_hpp...
export function addition(a: number, b: number) { return a + b; } export function subtraction(a: number, b: number) { return a - b; } The code is the same except the operator. Is it possible to avoid code duplication in such cases?
I'm new to C++ programming. I'm experienced in Java and its OOP paradigm. This code works well. I just need to make sure whether it's correct in terms of C++ programming standard. main.cpp #include <iostream> #include "ListNode.h" #include "LinkedList.h" using namespace std; int main(void) { LinkedList l; Li...
export function operator(a: number, b: number, operator: string, type: string): string | number { switch (operator) { case 'add': if (type == "answer") { return a + b; } else if (type == "assignment") { return a.toString() + " + " + b.toString(); ...
For classifying error reports, I need to generate an ID from an exception. That ID should be (more or less) unique a short alpha numeric string equal for equivalent exceptions (even on different systems) The following code seems to do the job: public static string GetExceptionID(this Exception ex) { i...
So,basically I am working on an algorithm for circular shifting a string upto a position.There are two parameters required here. String of text to shift Number of shifts required. For example: Given string: "Hello" Shifts: 3 Final: "ollHe" Ignore the limited validation here. import java.lang.*; import java.util.*; ...
I am using Laravel 5.3, and currently working on models. I have the following code: $result = TheEpisode::find($id)->with('TheParts')->take(1)->get()->each(function ($item) { $item->TheParts->makeHidden("title"); }); The purpose of this code is to display all the data from TheEpisode and TheParts, but exclude th...
Background I have decided to use this year's Advent Of Code to learn Haskell. I feel like I vaguely understand the language and can solve most of the problems with relative ease. However, the code I produce is not the most readable and possibly has inefficiencies. Any suggestions on how to improve readability and perfo...
I am looking for a review of my perfect TicTacToe algorithm. It will be split up into 3 parts: The function The GameState Class The game (NOT well designed) I am mainly looking for tips and comments on the first 2, but I will take comments / tips on the poorly designed game. alphabeta.py #Using wikipedia pseudocode w...
Wondering if there is anything I can improve upon my code? This method accepts a filename (usually will be the path to the file in txt format), the starting row count of that file and the total amount of rows of the file. The method is suppose to iterate through the starting row count passed in and then write into a ne...
I wrote this hangman program. It takes three words in an array, picks a random word and then the user guesses the letters. It's lengthy, but it's extremely simple and understandable. Suggestions are welcome, but keep in mind, my knowledge in java is limited. import java.util.*; public class Hangman { public static ...
package com.goman; public class BST { private BST left; private BST right; private int data; public BST(int data, BST left, BST right){ this.left = left; this.right = right; this.data = data; } public BST insert(BST node, BST root){ if(root == null){ ...
Based on a set of globs contained in a custom field within a package.json file, I'm trying to get a list of all the files that the glob matches. In my continual quest to get more familiar with Bluebird, I've chosen to use it to facilitate this task. What I have works, but I'm not sure if I am using the methods as inten...
I wrote the following as more of an experiment than anything else, but I thought it would be fun to share and maybe get some feedback! Motivation: I started looking at some functional languages and noticed how useful the |> pipeline operator is. I started wondering how it might be translated to the Java language. There...
I am using this code in a worksheet to check the condition, and based on the condition, copying the entire row of values in a different range of particular condition if true. For copying I am clearing the destination range each time and copying the same data with updated information on the same destination. This makes ...
I think this code is only simple math, but I'm posting it, because almost everyone fakes the scaling with unparenting, then parenting again. Vector3 originalParentScale = new Vector3; Vector3 originalScale = new Vector3; void Awake(){ originalScale = transform.localScale; originalParentScale = transform.parent....
I wrote this a while ago but wanted to see if I went about it the right way and if my brain is working correctly. I was thinking about these two projects the other day and I recently released the source. This game was originally for a Windows Form Game Jam so you have full context. This code worked but I always felt th...
I made a primality tester with trial division. I'm trying to make it as fast as possible and have reached the point now where I'm out of ideas. I use the generator approach and not lists because I found out that it's awfully slow to generate and checklists for big ranges. Does someone have ideas on how to improve the i...
I'm new to Python, and my first serious project was a FreeCell game. The game works, with lots of options to combine moves, save games, load them, etc. But I skimped on some specifics of Python. In particular, reading in options. import re vertical = False doubles = False autoReshuf = False savePosition = False saveOn...
I tried hard to come up with a function template computing a sliding average. A sliding average over data \$x_1, x_2, \dots, x_n\$ with window length \$k \leq n\$ is a sequence \$y_1, y_2, \dots, y_{n - k + 1}\$, where $$y_i = \frac{1}{k}\sum_{j = 0}^{k - 1} x_{i + j}.$$ Here is my attempt: mymath.h #ifndef MYMATH_H #d...
I have a ThreadPool class which has grown to a point where it is becoming difficult to keep all of this unit of work in mind. It is also becoming harder to read. For this reason I would like to break this class into component classes. First of all here is the class header with comments: //ThreadPool.h #ifndef THREADPO...
I am implementing the logic for a Checkers game in F#. I am writing my code in a library so it can be called from any UI provider, and am trying to do it in good FP style. I currently have the following code; each file is provided in the order of compilation: Checkers.fs This contains some unions and records that wil...
What do you think about this simple calculator? while True: print('Options:') print('Enter \'a\' to add two numbers') print('Enter \'s\' to subtract two numbers') print('Enter \'m\' to multiply two numbers') print('Enter \'d\' to divide two numbers') print('Enter \'q\' to quit the program') ...
I'm doing this HackerRank problem: Consider two sets of positive integers, \$A=\{a_0, a_1, \ldots, a_{n-1}\}\$ and \$B=\{b_0, b_1, \ldots, b_{m-1}\}\$. We say that a positive integer, \$x\$, is between sets \$A\$ and \$B\$ if the following conditions are satisfied: All elements in \$A\$ are factors of \$x\$. \$x\$ is...
I want to make a method arrayIntPush(3, {5,4,8}) that will return {5,4,8,3}. This method seems to work: public static int[] arrayIntPush(int item, int[] oldArray) { int len = oldArray.length; int[] newArray = (int[]) Array.newInstance(oldArray.getClass().getComponentType(), len + 1); System.arraycopy(oldArr...
I am a self - taught coder, and have been learning Java for the last 2 years. I have recently created a tic tac toe game in Java. I have rearranged the program into separate classes & methods. I am skeptical of how object-oriented my program is. I don't really want help on how to make the game better in visuals or any...
I need advice for this implementation that I made for a service access portable class library referenced to Xamarin.Android and Xamarin.Ios projects. For now, it works fine, but I have doubts about its performance or if it would crash on simultaneous calls. public class HttpClientBase : HttpClient { private static...
As a complete beginner, I didn't care about how the code looked as long as it works. However, now I am starting to think about how to make code be more maintainable and easier to read. I feel I have too many else ifs in the following code. I invite you to give me constructive criticism and suggestions. The purpose of t...
I've got a PR to add a feature to a Ruby application (Puppet) to allow Regex detection. Right now, the method only does comparison on exact string matching: defaultfor :operatingsystem => :fedora, :operatingsystemmajrelease => ['22', '23', '24'] This is annoying, as we have to add in new values everytime a new Fedor...
I've written my own implementation of strcat in C. char* my_strcat(char *str1, char *str2) { int len_str1 = 0, len_str2 = 0, len_str3; for (int i = 0; str1[i] !='\0'; i++) { len_str1++; } for (int i = 0; str2[i] != '\0'; i++) { len_str2++; } len_str3 = len_str1 + len_str2; cha...
I have this procedure to realise a find and replace on a word document. Since I have text boxes, using this way to do this is a bit a slower than what I'd like it to be, if it were just text on a plain doc document or tables and using just: Document.Content.Find.Execute(FindText:=Find, MatchWholeWord:=True, ReplaceWit...
Here goes my first stack implementation with go New to the go language and it's been ages since I implemented a stack Would love to discuss the data structure implementation itself and how "goish" the code looks. package stack import "errors" var ( errEmptyStack = errors.New("Stack is empty") ) type node struct ...
Recently, I was given a math assignment to calculate Gini Indexes for a table of percent distributions of aggregate income. The table takes the form of: Year 1st Quintile 2nd Quintile 3rd Quintile 4th Quintile 5th Quintile ---- ------------ ------------ ------------ ------------ ----------...
I'm trying to solve the following Advent of Code problem in F# for practice. Description of problem (can be found here): Basically, there's a 'key pad' that I need to figure the combination to. To do that, I have to follow instructions in the form 'U'/'D'/'L'/'R' to move a key up, down, left, or right in a gird of key...
I wanted to write something that would find all pyramid words within a supplied text file or list of strings. An example of a pyramid word is the word "deadheaded". It has one of the letter "h", two of "a", three of "e", and four of "d". This would form a pyramid if you were to stack the letters: h a a e e e ...
I'm working on this valid palindrome problem. Any advice on code bug, better idea for low algorithm execution time complexity, code style, etc. are highly appreciated. Problem Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. Example "A man, a plan, a canal...
I have the following piece of Perl script for updating an Oracle database. It's working perfectly fine, but I want to know how I can simplify this script. use DBI; my $dbh; my $bad_form = "text.txt"; open (OUT, $bad_form) or die "Could not open $bad_form"; while (<OUT>){ chomp $_; my ($item_id, $description, $fo...
I have written a solution to find the occurrence of a common number in a n lists. I am just concerned if this is the best solution? Please suggest the best way to do it. import java.util.Arrays; import java.util.Collections; import java.util.List; public class CommonNumberFinder { final static List<Number> list1 ...
I am currently writing a small configuration API for myself, i want to use it to easily read/write to a file, however, i want to make sure it's efficient and get some other options into the field of my programming. How can i make my classes even more efficient? This is the class for the options for comments, headers an...
This is a scenario where we keep a single instance(as in Singleton Pattern) to get the configuration of an application. Below is the main class and i set values to the configuarion values here and call the methods of the other classes to check if they are getting the correct values. public class A{ public static vo...
Aim: randomly generate \$n\$ numbers between \$a\$ and \$b\$ with (roughly) mean \$m\$. Problem: The simple beginner's code I wrote becomes very inefficient as \$m\$ moves away from \$\frac{a + b}{2}\$. import random import numpy as np import time low = 0 high = 100 data = 50 def lst_w_mean(target): HT = [x for ...
I created a really basic game class. A game has GameObject instances, which currently have a position only. This code is running on the client, and in each loop iteration: The client receives the updates from the server It executes the received events The client updates the game state I created a map to store game ob...
I have started doing Kattis challenges from their website. For now I am still at the low complexity ones. The first line of input contains a single positive integer T≤50 indicating the number of test cases. The first line of each test case also contains a single positive integer n indicating the number of elements av...