instruction
stringlengths
71
71.9k
I have a Windows Store and Windows Phone app, and in this app I have many pages like this: <Grid Background="Transparent"> <ScrollViewer Style="{StaticResource DataPage}"> <StackPanel> <TextBlock> Some text here: <LineBreak/> </TextBlock> <...
I wrote a simple extension to convert a number into a hours and minutes string in the ##:## format. This seems like a good way to do it, but let me know what you think. Number.prototype.display_hours_minutes = function () { var remainder = this % 1; var remainderTime = new Date(remainder * 3600 * 1000); return ('...
I've just done Problem 12 of Project Euler: What is the value of the first triangle number to have over five hundred divisors? The \$N\$'th triangle number is the sum of all natural numbers from \$1\$ to \$N\$, for example, the 5th triangle number is \$1 + 2 + 3 + 4 + 5 = 15\$ I get the correct answer in around 2.5 s...
I've the following problem: Print all valid phone numbers of length n subject to following constraints: 1.If a number contains a 4, it should start with 4 2.No two consecutive digits can be same 3.Three digits (e.g. 7,2,9) will be entirely disallowed, take as input Here's my solution: public...
I have not worked with jQuery for years so my knowledge of it is extremely limited. I wrote the following form and received a comment elsewhere saying: This is some of the worst JavaScript I've seen. Your selectors are terrible ($('div#foo') instead of $('#foo')), you copy-paste code all over the place, you retur...
In my webpage, I have the following @media queries: /* Smartphones (iPhone 3GS/4 and others; portrait and landscape) */ @media only screen and (min-width: 320px) and (max-width: 480px){ html { font-size: 60%; } } /* iPhone 5 (portrait and landscape) */ @media only screen and (min-width: 320px) and (ma...
This is a followup to: Pointer class/handle Please review this pointer class. template<typename T> class Ptr { public: Ptr(T* t, int s = 1) { sz = s; p = new T[sz]; for (int i = 0; i < sz; ++i) { p[i] = t[i]; } } Ptr(const Ptr& t) { sz = t.sz; p...
As a practice for interacting with system commands, I wrote a Haskell program that compiles a .tex file specified by the argument. When one execute this program: If no argument is specified, print "Specify a file!" then exit If the specified file does not exist, print "File not found." then exit If the specified file ...
I just finished Project Euler #10 in Swift, and since there is not any version yet on Code Review, I would like to have some comments on what I did to try to improve it. I hope I learned some from the previous code reviews :). The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17. Find the sum of all the primes below t...
I created this script to take informations "at-the-moment" of this site: Pictures of name channel Name of channel Pictures channel Times Title Type My script (Work): <?php $url="http://www.programme-tv.net/programme/toutes-les-chaines/en-ce-moment.html#Grandes%20cha%C3%AEnes"; $code_page = file_get_contents($url); p...
I'm looking for a way to generate the following the series of numbers given the version number on the left. For example, given "2", generate [6, 18]. The series of numbers is from the alignment pattern locations for different versions of QR codes. V2 6 18 V3 6 22 V4 6 26 V5 6 30 V6 6 34 V7 6 22 38 ...
We are working on an application with a splash screen. After a few seconds/loading all the data, a login dialog appears inside the splash screen, asking you to enter username and password. Think of a Visual Studio splash screen when you run it for the first time. Here is how I have done it: SplashScreenView.xaml.cs: pu...
Could you review it and said if it's written good and/or is better way to do that? My algorithm is: Input roomNumber If length of roomNumber is 8 set goToRoom state Enabled and color 0xFFFFFFFF Else set goToRoom state Disabled and color 0xBBFFFFFF Code of that algorithm is: public class Join_room_screen extend...
I have Conway's Game of Life working now and was hoping for direction on: Unclear code - where would comments make it clearer? Poor design choices - I already know of one in the countNeighbors method, as it needs knowledge of the game object's name Improvements to make - I have already noted that I wish to add more te...
Here is my implementation of a lock-free thread-safe Fibonacci number generator. Is it correct? The idea is to use an immutable holder for previous and current numbers (since it's hard to change two values atomically at the same time) and AtomicReference which points to the current Fibonacci number. Lock-free public cl...
I was practicing implementing a hash function. I tried to use linear probing to insert in hash table. The insertion is working alright but I am not satisfied with the recursion. It doesn't feel like "good recursion". The Linear_Probing function instead of being recursive itself uses two other functions (excluding hash ...
sumMultiples() is a working general solution to Project Euler's first problem. Don't read it if you want to try it yourself. This question is about preserving this general nature while improving performance, perhaps using math tricks like sumSkip() and sumIndetity(). Unfortunately everything I find that takes advan...
This code is attributed to Stack Overflow itself here. The path which adds to the sum, which need not be starting from the root, not be ending at the leaf, i.e. a path can be between root and a leaf. I'm looking for code review, optimizations and best practices. I'm also looking for a solution better than \$O(n^2)\$ ti...
This is a programming problem: Write a program that finds and displays all pairs of 5-digit numbers that between them use the digits 0 through 9 once each, such that the first number divided by the second is equal to an integer N so that: abcde / fghij = N where each letter represents a different digit. The first...
I'm trying to set multiple attributes in d3 but I get an error for the stroke width attribute due to the dash. I can get around this by chaining another attribute's call but I would like to keep them all in one call if I can. Is this possible? var edges = svg.selectAll("line") .data(data.edges) .enter()...
I am currently implementing a fun project involving lambdas and this project makes heavy use of the ability of Java 8 to have default methods in interfaces. But when does such "heavy use" turn into an outright abuse? Here is one example of an interface which I have defined, and its 4 methods may extend to even more in ...
I have tried to implement two methods, one for finding the size of the tree and the other for finding the height of the tree. Can they be optimized further? package trees; import java.util.LinkedList; import java.util.TreeSet; public class TreeNodeImpl { public TreeNodeImpl left ; public TreeNodeImpl ...
This is probably one of the many follow-ups coming. What I have edited: Added equals() and hashCode() Added . and , to my Morse code "dictionary" Used a Pattern for regex checking Edited method names Concerns: Any bad practices in the new code? Does it "smell"? import java.util.regex.Pattern; public class MorseSt...
I'm trying to create a little block presenter for Laravel which displays blocks of content in certain positions. I have 2 classes, BlockFactory and Block. The BlockFactory contains all the blocks and creates them whereas the Block class is exactly just that: a simple block. As can be seen in the code below, when I'm cr...
Is this implementation correct? Do you find any threading problem? Also, what parts of the code can be changed to be more C++11-ish? #include <iostream> #include <vector> #include <thread> #include <random> #include <condition_variable> namespace { int sleep_for_random_time() { std::random_device rd; ...
I have tried to write JavaScript code to check whether I can form a word from the given string (jumbled): function findWord(word, jumbledLetters, isSameLength) { if(isSameLength && word.length !== jumbledLetters.length) return false; var uniquePosition = {}; for(var i = 0; i< word.length; i++) for(var j=0; j< jumbledL...
I tried to solve Project Euler 12 with a first very naive solution by myself. It took nearly 30 minutes to run until it found the solution. Then I made a change in the function getDivisorCount which should have made the run time to about the square root of the original code, about 5 minutes. At least this was my opinio...
I'm making a project to calculate road-tax prices based on a vehicle's weight, type and vehicle's owner's province. For that I've received data in 9 different JavaScript files, all those files contain circa 12 arrays. I've been told I could just do this in arrays as well. I've made this data-mapper: var roadTaxData = {...
This Python module is supposed to be a generic engine for games of life. By generic, I mean that it is supposed to be able to handle different kind of rules (not just Conway's) and graphs (not just square grids). The implementation presented here comes with an example of a 4-state rule that could be used on Penrose til...
This is a follow-up to: Pointer handle - follow-up Pointer class/handle Please review my pointer class. template<typename T> class Ptr { public: Ptr(T* t, int s = 1) : sz{s<1 ? throw std::logic_error("Invalid sz parameter") : s} { sz = s; p = new T[sz]; std::copy(t,t+sz,p); } Ptr(...
As a casual Rubyist I am mainly interested, how ideomatic my solution is. class Integer def divisible_by?(n) (self % n).zero? end end def fizzbuzz(upper_bound) 1.upto(upper_bound).map do |number| next "fizzbuzz" if number.divisible_by? 3 and number.divisible_by? 5 next "fizz" if number.divisible_by?...
I wrote a tiny command line tool that converts ADF audio files from the Grand Theft Auto - Vice City game to MP3 files that can be played outside the game. The ADF file format stores the game soundtracks and radio stations. These in turn are just MP3 files that had every byte XORed with the decimal constant 34. My appl...
Please note the following: All edges are directed Removal of edges/nodges is not implemented yet A user of the class Graph can never (hopefully) access a Node directly If one tries to add an edge to a node that does not exist, insert_edge() will do nothing. A Vertex cannot point to another vertex with several edges. ...
The idea I have in my head is this: I am not sure if I need the index variable in consumer and producer. Moreover, I want to know if it is OK like this (it seems to work), or it is just some stupid working code. Can it be more clever/efficient? Leave the readability for me. My code will use the POSIX semaphore mutex i...
I've built an anagram solver in Python 2.7. It goes through a text file with over 100,000 words and checks if any permutations of the input matches the line. It works great, except it is very slow. I've tried making the text file a list with each line as a list item, but the text file is too big to do that. This is the...
I wrote a method to check if each parenthesis in a string is closed. It should take into account the order in which a parenthesis is presented, e.g. "hello)goodbye(" should return false even though there are an equal number of opening and closing parentheses. My method is as follows: def balance(chars: List[Char]): Boo...
Previous question: Text-based Tetris game with CRTP - follow-up Summary of improvements: Fixed issues preventing the code from compiling on Clang Implemented override specifier Fixed single letter type classes Elimination of magic numbers Removed unnecessary Block class Summary of new features: Renamed clonable clas...
I have a file containing information about the session of students. The structure of this file is: group number, student name, exams, and tests. debt() function find and print the names of underachieving students. student_score() calculate the average score of groups group_score() calculate the average score of each s...
I am writing an application that shows a news feed, much like Instagram. For this, I have a function in the model to select the feeds as shown in the code. For some reason, this runs quite slow and I am sure my code is the issue. Is there something I could do to optimise this. public static function getPublicFeed($user...
I have a sparse matrix (term-document) containing integers (word counts/tf) and I am trying to compute the tf-idf, for every non-zero value in the sparse-matrix. The formula for tf-idf I am using is: log(1 + tf) * log(N / (1 + df)) # N is the number of coloumns of the matrix # tf is the value at a cell of the matrix ...
I am implementing an OpenGL ES 2.0 renderer in c. I want to use quaternions for rotations. Please take a look at the way I am implementing the rotation math. Everything looks as expected when the program runs, but since I am very new to using quaternions, I am wondering if I am doing things in a sub-optimal way. The id...
I've seen many implementations of Sieve of Eratosthenes in Scheme, but I thought I'd try to write one that is both space- and time-efficient: Space-efficient: I use R7RS bytevectors as a bitset, which encodes odd numbers starting with 3 (so bit 0 = 3, bit 1 = 5, bit 2 = 7, etc.). Time-efficient: Many implementations s...
This function checks an array for duplicated values. If it finds a duplicate value, it increments the variable name repeatedTime and then if repeatedTime is greater than 1 it calls a randomize function which produce different values in the array that was passed to the function. It repeats these steps until a duplicated...
I'm new to both GTK and Haskell, so I'd appreciate any in both. I'm making an application which for the purposes of this question is just drawing a window that shows a red circle getting larger until it touches the edges of the window. I have a CircleGUI.hs module which defines the following functions: module CircleGUI...
This is my second follow-up. Major changes made: Use a Map instead of an enum for the Morse characters Added (space) in Morse characters Added method play() to play the Morse code Comments are now JavaDoc comments Moved CHAR_SEPARATOR and WORD_SEPARATOR to the class that contains the Map of characters MorseString.ja...
I have written a pong game in C++ using SDL2.0 for the graphics. I have a couple of questions regarding this code: How can I make the AI better, in such a way that it is actually dumber? Right now, my AI can return the ball to me every time, which is unfair. I want the player to be able to score at least some of the t...
We have been working on a mutation analysis tool for Haskell tests called MuCheck. It accepts any Haskell source file, and a function name to mutate, applies a defined set of mutation operators on it, and runs the specified test suite on it. The mutation of code is accomplished using the haskell-src-ext library, and SY...
This is my code. All comments welcome. Last time run it only took 335 milliseconds: static bool CheckMultiples(int val) { for (int i = 1; i <= 20; i++) { if (val % i != 0) return false; } return true; } static void Main(string[] args) { Stopwatch s = new Stopwatch(); s.St...
I'm looking for following kind of feedback: Firstly, is the use of a cursor an overkill here? Is there a simpler way to do what I'm doing in SQL? Could the script go terribly wrong? I have limited SQL experience, how does it look? Any standards that I'm not following? Bear in mind that this is a one-time script to be...
The challenge: Given a String, for each digit in that original string, replace that digit with that many occurrences of the character following it. So a3tx2z yields attttxzzz. My Solution: import java.util.Scanner; public class Standford1 { public static void main(String[] args) { Scanner input = new Scann...
We are designing a small framework to create and send messages to external parties as a result of internal events. I am reasonably happy with the design, but I am wandering if it can be further improved. The external messages are large and complex and involve getting data from different areas in the system and are sen...
Out of curiosity, I built a recursive Sieve of Eratosthenes in Python and I was wondering how it could be improved for efficiency and how it can improved to be aligned with python best practices. Essentially, there is a recursive function (coded horrendously IMO), filter_multiples, which removes the multiples of some n...
I hate using unnecessary catch blocks and I like to see my code look beautiful. In most of the cases in my project, which is a web application, I can't declare many exceptions as checked exceptions as there is little that my client (browser) can do to recover from the exception. However, only if there is a way that the...
A Collatz sequence for a given positive integer \$n\$ is to take half of \$n\$ if even and \$3n+1\$ if \$n\$ is odd; repeat until the value goes to \$1\$. The question is which number from 1 to 1,000,000 has the longest Collatz sequence? The Collatz sequence for \$n=13\$ from Project Euler #14: 13 → 40 → 20 → 10 ...
I'm moving a system over to PDO and since the queries are parameterized, I need to specify both the type and value of each parameter when preparing them. Right now I have a prepare method to create the PDOStatement object: /** * Prepares a statement * @param string $sql The query * @param array $data The data to bin...
Merge function: void merge(int outputArray[], int firstArray[], int sizeFirst, int secondArray[], int sizeSecond){ int p = 0; int p1 = 0; int p2 = 0; while(p1 < sizeFirst && p2 < sizeSecond){ if(first[p1] < second[p2]) outputArray[p++] = firstArray[p1++]; else o...
I want to do simple encryption using PHP 5.5. By “simple” I mean I want to use native PHP functions. I have created this code that works, can it be improved? It's to encrypt/decrypt strings and binary files that are to be stored in a database and accessed via a website. Assume that it is done over SSL and that the pass...
I have written a simple wrapper for WinSCP in C#. I have written it to simplify SFTP connections I will needing to perform. public class WinSCPConn : IDisposable { //private fields private SessionOptions sessionOptions; private TransferOptions transferOptions; private Session session; ...
I have created a system where user selects files from their Google Drive to be uploaded into Parse. I have done so separately though, where I have one code that allows user to select an item from Google Drive, and one that allows user to upload a file from their computer into parse. Google Drive (Using Google drive pic...
I am using a recursive directory scan to find all objects inside a Unity3D project. After that, I wish to move all these files to a sorted List. Is there a cleaner and/or more optimal way of doing so? I have the feeling the AssignFileToList could be less complex than it currently is. //Requestable total values public i...
I am working on a web app that uses a WebSocket to log in users. I would like to minimize bandwidth usage by using binary messages. I came up with the following, and would like to know whether there is something better I could be doing: -define(LOGIN, 1). websocket_handle({binary, <<?LOGIN:8,LengthUser:8, Rest/bitstri...
I have tried to implement an in-place quicksort Algorithm in Python 2. Please suggest how I can Make the code more efficient Increase readability Improve writing style Make it more Pythonic def swap(x,y): return y,x def sort(ar, start, end, l): if start<end-1: # pivot element is taken as the last...
How can I improve this code? template<class T> class Queue { public: Queue(const std::initializer_list<T>& i) :elem{i} {} int size() const { return elem.size(); } bool empty() const { return elem.empty(); } void enqueue(T&&); void dequeue(); T peek(); T& operator[](st...
I'm trying to read doubles from a relatively small binary file. This currently reads a 100 KB file in about 6 milliseconds in my system. I would like to reduce that if possible. void readNParseData(const char* filePath, vector<double> *&data){ ifstream ifs(filePath, ios::in | ios::binary); // If this is a val...
Input: { 1: [2,3], 2:[4], 3: [5,6], 4:[6] } Expected output: [[1, 2, 4, 6], [1, 3, 5], [1, 3, 6]] My Code: def parse(node, tree): result = [] if node not in tree: return [[node]] else: res = [] for next_node in tree[node]: res.extend(parse(next_node, tree)) for ...
I am doing the Python Koans to practise Python a bit more and I got to the greed dice project. It is a very simple dice game that scores a set of up to five rolls. These are the rules: # A greed roll is scored as follows: # # * A set of three ones is 1000 points # # * A set of three numbers (other than ones) is worth ...
I am displaying menus and submenus in my WinRT app, and I think I am doing it wrong. I have thought I was doing it wrong for a long time, so here it is for review. This is the section in my ViewModel. Probably needless to say, both Remove() and NewSelectionWS() have had large quantities of nearly identical code remov...
When this ViewModel loads we kick off the IsAuthenticatedCommand: If the result of IsAuthenticatedCommand is false we set the value of NeedsToLogin to true. If the result of IsAuthenticatedCommand is true we set the value of IsAuthenticated to true. There are (subscriptions?) to both NeedsToLogin and IsAuthenticated ...
A split-string function seems to be missing in R7RS. I came up with the following implementation today: (define (split-string delim str) (let ((add (lambda (current output) (cons (list->string (reverse current)) output)))) (let loop ((input (string->list str)) (output #f) ...
Background I created a simple class to reflect emotion classification based on the Lövheim cube. The code is not scientific at all, and I just did it for fun, but I want all code I write to be as Pythonic and efficient as possible, so I was hoping for some help refactoring it. Code Purpose Class Emoter takes in seroton...
If it is possible, could someone please revise my code to see if any improvements can be made? <html> <head> <title>Roamfree - Official Website</title> <link rel="stylesheet" href="index.css"> <style> ul { list-style-type: none; margin: 25px; padding: 0; overflow: hidden; } li { float: cent...
I am relatively new to programming and OOP in PHP. I tried to create a Simple Login Register Script using my basic knowledge of OOP. I'm sure my code can be better in a lot of way. I'm trying to code better and learn new things. Be harsh, please find out as many small noob mistakes as you can. Suggestions and Feedbacks...
I seek the assessment of which code block is more efficient in Java at detecting the byte sequence of 00 00 00 01 and 00 00 01 in a byte array. Version 1 for (int i = 0; i < frame.length - 4; i++) { if (frame[i] == 0) { if (frame[i + 1] == 0) { if (frame[i + 2] == 0) { ...
I am looking for best practice in handling conditions inside the controller actions in ASP.NET MVC: public ActionResult Edit(int Id = 0) { var Item = _todoListItemsRepository.Find(Id); if (Item == null) return View("NotFound"); if (!Item.IsAuthorized()) return View("NotValidOwner"); return View...
I perform an if-check (commented in the code) to determine whether a user can access certain actions or not. The user will be redirected to the index page if they try to access the login.action while already logged in. I have this kind of if-check in many of my Action classes (containsKey() or !containsKey(), depending...
I started actually learning a little programming last year, as opposed to just hacking away at libraries and found fragments. For a WordPress plugin I needed to navigate through weeks, which I thought would be pretty easy. Well it should have been, but my method of using the week and the year returned by php based on t...
I wrote this function to format a given sentence via Java, and I'm wondering if there is a better way of doing this without use of external libraries, such as with regex. public class ChatFormat { public static void main(String[] args) { String input = "hello, it's a monday today and i think i'll go to the...
I am working on a pathfinding program / algorithm, and I have the following class: [System.Serializable] public class UnitTileCosts { int[] tileCosts; public UnitTileCosts() { //empty constructor uses default value of 1 for all fields GenerateDefaults(); } public UnitTileCosts(Dict...
I am trying to optimize my script that loops through a folder and extracts only the part of a file name before a date and the header of the file and outputs it into a different file using a delimiter. I feel the script is robust and I want to refactor it. If there is also a better way, please tell me. #!/bin/bash # scr...
I was reading this question and realized that I didn't know Python well enough to critique the algorithm. So I wrote a Java solution instead, which is inappropriate for that question. Since there's no Java solution for #14, I'm posting this one. Project Euler #14 problem statement The following iterative sequence ...
This is a basic implementation of a stack. Can anyone please review it and let me know how I can improve this code and overall coding practice? #include"iostream" #define MAX_SIZE 5 using namespace std; class Mystack { private: int A[MAX_SIZE]; int top; public: Mystack()...
I was studying for arrays from coding-bat and encountered this: The question is: (fix34) Return an array that contains exactly the same numbers as the given array, but rearranged so that every 3 is immediately followed by a 4. Do not move the 3's, but every other number may move. The array contains the same numb...
Script designed to avoid manually edit configuration files by support. Config file example: $ cat ../secure/test.property [Connection settings] jdbc.main.url = jdbc:oracle:thin:@host1 jdbc.main.username = USER jdbc.main.password = pass [Mail settings] mail.smtp.host=127.0.0.1 mail.smtp.port=25 mail.smtp.on=false mail....
I'm programming code with MySQLi prepared statements. I'm a beginner and just want to ask to experts if my code is correct. function getPaymentMethodName( $id ) { global $mysqli; if ( $stmt = $mysqli->prepare( 'SELECT name FROM `payment_methods` WHERE id = ?' ) ) { if ( $stmt->bind_param( 'i', $id ) ) {...
Since I'm still learning jQuery, I would like to have some feedback on my code: var showImgage = function() { var selection = $(this).val(); switch(selection) { case 'Monica Bellud': $('#Belluci').removeClass().addClass('show'); $('#Andres').removeClass().addClass('hide'); $('#Seydoux').removeClass().ad...
This is a follow up question of Importing different type of files into Lists. Where the original lists are acquired. In this script I am processing the obtained lists, and comparing them with each other to determine whether or not a used material has duplicate functions. This using their most commonly known traits, wh...
I am currently working on a little binary patcher. My current code works fine but I do want my code to be optimized (fast) and as clean as possible. Could you all please help me review this? IDE: Delphi 7 and XE7 const OriginalByte: array [0 .. 55] of Byte = ($64, $69, $6E, $67, $20, $6D, $65, $20, $68, $69, $73,...
This is an implementation of a stack where I have used vectors. Can anyone please review it and let me know how I can improve this code and overall coding practice? #include"iostream" class Mystack { private: int *A; int top; int size; public: Mystack(int capacity); void push(int x); int pop...
I've finally got a working Proxy pattern. The original task is presented here. My test case is on coliru. It appears to flow through the correct pathways, however I am grateful for feedback and possible improvements. EDIT: I've reworked the code to provide sensible trace output, so it is possible to examine the flow un...
What is the best way to refactor the following code to avoid duplication? // JQuery FORM Functions $(document).on('change','.submittable',function(){ //save current input field into hidden input 'focus_field' if it exists if($('input#focus_field').length){ var $focus_field = $(this).attr('i...
I have some code that will brute force solve the following problem: Given a set of x coins and a target sum to reach, what is the fewest number of coins required to reach that target? The code so far: import java.util.ArrayList; import java.util.Arrays; public class coinsSum { public static int min = Integer.MAX...
I have this Java implementation of Kruskal's algorithm. It solves a tiny problem instance correctly, yet I am not quite sure, whether my implementation is correct. The code as follows: MSTFinder.java package net.coderodde.graph.mst; import java.util.List; import net.coderodde.graph.UndirectedGraphEdge; import net.code...
I finished the Python Koans because I wanted to practise Python and I completed the extra assignment which is the Greed Game (see the rules here). I think there are no flaws but you never know. import random class DiceSet(object): def __init__(self): self._values = None @property def values(self):...
I am very new to HTML and I've decided to attempt to put what I know into an HTML page that allows you to enter any amount of numbers, separated by commas, and would display the sum of all the numbers below. <!DOCTYPE html> <html> <head> <title>Sum of two numbers</title> </head> <body> <h1>Enter any amount of ...
I had already posted this question at here and have tried to incorporate some of the suggestions given. Kindly let me know if there are still some concerns/suggestions/improvements in the code mentioned below. #include"iostream" #define MAX_SIZE 5 class Mystack { private: int A[MAX_SIZE]; int top; public: M...
How do I decrease time, especially in sorting? Given a list of numbers, you are to sort them in non-decreasing order. Input t – the number of numbers in list, then t lines follow [\$t \le 10^6\$]. Each line contains one integer: N [\$0 \le N \le 10^6\$] Output Given numbers in non-decreasing order. Example Input: 5 5...
I have a Component that is used for all Active Directory queries. The function below is used heavily perhaps even milions of times each day. Performance is a feature! It's used on servers and I want to reduce memory press on these servers (when the GC is collecting the server websites etc are not responding... well of ...
I have the following code for importing Yahoo contacts from an address book, but it imports only the top 30 contacts, not all of the contacts. Anyways, I think another alternative (and better) way of doing it is by using another latest Yahoo API. private const string _addressBookUrl = "http://address.mail.yahoo...
This is the code I wrote to compute the newton's square root of a number. I aimed for extreme clarity over efficiency and I have put an abundant docstring at the start of the newton_sqrt function where I describe the main formula and explain all the parameters. This function is not meant to be fast (standard library is...
I wrote my first WPF UserControl today, and I would like you to review it. Its purpose is to have images by default resize with the page, but expand to full size with a double-click: <UserControl x:Class="MyApp.ImageDisplay" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://...