instruction
stringlengths
71
71.9k
I am working on rewriting an application in Laravel 5.1. I am new to the exception handling technique introduced in 5.0. I have overlooked taking advantage of throwing/catching exceptions frequently in the past, but am working on this now. I am most likely not up to speed on some of the best practices. public function ...
The existing design of class DList and DListNode is taken. The main criteria is to do successive updates in \$O(1)\$ time. Part III (3 points) Implement a "lockable" doubly-linked list ADT: a list in which any node can be "locked." A locked node can never be removed from its list. Any attempt to remove a locked no...
Any suggestions for improving this? I'm hoping for some JavaScript object structure / code integrity type recommendations rather than style or CSS. var list = [ {name: 'Afghanistan', code: 'AF'}, {name: 'Åland Islands', code: 'AX'}, {name: 'Albania', code: 'AL'}, {name: 'Algeria', code: 'DZ'}, ...
I'm trying to figure out a better way to have one query here. I want to be able to send something to last where statement a wildcard so I can select all vendors. Right now if I don't include that line it doesn't filter by vendor so I essentially get all the purchase requests. Any thoughts of a cleaner way to do these q...
I have this controller that I call via Ajax, where I update the likes of a post. I have two methods in the user model: already_like_post?: Where I pass the posted ID and return true or false if the post is already liked. dislike_post: Delete the user like for given post. class LikesController < ApplicationController...
What I need to accomplish is matching the QR code to the one I have created. This code works, except it takes at least 30 seconds to verify that it has matched my QR Code. How can I make it faster? QRCodeVC.h #import <UIKit/UIKit.h> #import <AVFoundation/AVFoundation.h> @interface QRCodeVC : UIViewController <AVCaptur...
I am a newbie at programming and I helped my dad with making this program which orders multiple products to a website from a table of Excel. It involves 3 processes: Passing orders from Excel to website by injecting JavaScript. The website provides a function for ordering a product: (in JavaScript) updateProduct('{ref...
This is my final project for my second Java class! I would like to get some feedback on it to see where and what I can improve. There are five class files: GuiMusic This contains all all of the the Swing and AWT components and the key listeners. ScrollPaneSync Synchronizes the scroll bars on each JPanel. Stringbillde...
This is a little tricky to explain, so bear with me. Suppose you have an integer X and a list of integers A. Let A` be a copy of A where all values A[i] != X are replaced by -X. For example, X = 5 A = [1, 3, 5, 5, 1, 5, 4, 1, 8] would result in A` = [-5, -5, 5, 5, -5, 5, -5, -5, -5] The task is to find a subsequenc...
After playing Mancala with my brother, I thought coding the game would be a fun project to practice my abilities in C++. I am relatively new to programming, having only done a few small projects to experiment with the basic features of the language. So I consider this to be my first legitimate application of my skills...
This code takes an image and detects a global shortest path from the top to bottom row, with the requirement that top and bottom column index be the same. For this, it scans through each element on the top row using Dijkstra's algorithm towards its corresponding point on the bottom row. The shortest path is defined as ...
This is a BitSet wrapper class to act as a Sieve abstraction for a prime calculator. Review for performance and Java/Java 8/Guava best practices. package info.simpll.immense.prime; import com.google.common.base.MoreObjects; import java.math.BigInteger; import java.util.BitSet; import java.util.Objects; import java.ut...
I'm trying to think of a better way to write the below Javascript/NodeJS code without having to check the value of the boolean using an if statement. I know this can be accomplished with a ternary, but that would look ugly. This is of course only an example, I'm sure there's a better way to write this; however I'm spec...
I have hundreds of .mp3 files in a single directory of the same naming format, title_YYYY-MM-DD.mp3, with maybe 30 different titles. Here is an example two different titles: vision_am_2015-08-04.mp3 vision_am_2015-08-03.mp3 vision_am_2015-07-31.mp3 vision_am_2015-07-30.mp3 lum_pro_2015-08-04.mp3 lum_pro_2015-08-03.mp...
This is an algorithm that takes in an ArrayList of objects that store information on meeting/event schedules. This algorithm's purpose is to check and see what the user's status is based on their current time. The case scenarios are: The user's current time is before all meetings The user's current time is during a me...
Oftentimes I find myself converting pandas.DataFrame objects to lists of formatted row strings, so I can print the rows into, e.g. a tkinter.Listbox. To do this, I have been utilizing pandas.DataFrame.to_string. There is a lot of nice functionality built into the method, but when the number of dataframe rows/columns ge...
I wrote this program in response to a CodeGolf challenge that required generating this sequence of "untouchable" numbers. This sequence can be found on OEIS as A005114. My initial implementation was prohibitively slow when asked for anything other than the first few terms so, I wrote this implementation with the goal ...
This is actually a function from the first commit of the git source code, for the purpose stated in the title: static int verify_path(char *path) { char c; goto inside; for (;;) { if (!c) return 1; if (c == '/') { inside: c = *path++; if (c != '/' && c != '.' && c != '\...
Using JavaScript cloud code, I'm trying to bulk convert a huge number of URL entries into actual files uploaded to Parse.com. This code works; I just want to make it cleaner/nicer. Parse.Cloud.job("convertFiles", function(request, status) { //Cuts the rundata out of poor runs function sleep(milliseconds) { ...
I am creating a class project which involves two classes: Library and Book. I would like a general review on the code. public class Book { private String title; private String author; private String summary; public Book() { title = ""; author = ""; summary = ""; } publi...
In a response to this post I wrote a solution in Python. It passed all the test cases given, so I would like help making it more pythonic and reducing the almost repeated lines. Link to the source of the question on HackerRank. # input M, N, rotations = map(int, input().split()) matrix = [] for row in range(M): mat...
I wrote this method that adds two integers in the form of strings together. This way I can add large integers without overflowing. How efficient is the code that I wrote? I am by no means a great coder, but I would consider myself somewhat decent. Is there anyway that would make it better? I am a self taught coder an...
I have an .mdf DB file and I want to use this DB for integration testing. In every test I should: Create a copy of an .mdf file. Attach DB to an .mdf copy file Do testing Detach DB copy Delete DB copy Just to make all clear, integration testing should look something like this: [TestFixture] public class WebJ...
It is a set of edges of a graph given. An edge is given as an array of its endpoints, e.g. [:a, :b]. The array can contain an arbitrary amount of endpoints. Therefore [] and [:b, :c, :d] are also valid edges. I want to find all islands which means that I looking for unconnected sets of nodes. Here is my Ruby solution. ...
namespace Impl { template<typename T> class SharedPtrCounter { public: SharedPtrCounter(T* e) : element(e) { } void IncrementFlimsyCounter() { ++flimsyCounter; } void DecrementFlimsyCounter() { if(--flimsyCounter ...
This method is written for much larger Web application, but I just extracted it and added class and main method around it so that it can be debugged locally. Browser detection is done in another method, then this one is called to precisely determine IE version, i.e. if it is in compatibility mode or not. All other chec...
I'm currently working on this for my own practice. I get 4 digits and an operation. The input is x1 y1 op x2 y2 and the fraction is x1/y1 and x2/y2. If I get the input: 1 3 + 1 2 then it's 1/3 + 1/2 and the answer should be given the minimal fractional so it's 5/6. I pass the testcases I get and I can't figure out what...
I have written this linq-to-sql query to insert a bunch of customer care database analysis detail records: DataClasses1DataContext behzad = new DataClasses1DataContext(conn); var query = (from p in behzad.Customer_Care_Database_Analysis_TEMPs select p).ToArray(); for (i...
I've already written this macro that does exactly what I want it to do. However, it's quite large, and I may wish to expand on it in future. Basically, the purpose is to copy and paste items from a horizontal list (where RNG is equal to the number of items there), and take one cell from each. Any suggestions in cutting...
I'm working on a skill tree calculator for a game and I made a method that checks whether or not it can subtract a point from the skill and then proceeds to do so. Everything is working as it should, however it's very slow when this method is executed in rapid succession (i.e. when 5 points are subtract at the same tim...
I am building a JAX-WS client with a GUI that connects to a server by accepting self-signed server certificates (when it uses HTTPS). The accepting of the certificates is not automatic, it is similar to what happens in any browser when you try to connect to a website that is not trusted. That is, usually a security pop...
I'd like a little help here calculating the view matrix for OpenGL based on the lookat type function: vec3f eye = {0, 0, 0}; vec3f center = {10, 2, 21}; vec3f up = {0, 1, 0}; mat4* vm; mat4LookAt(vm, &eye, &center, &up); mat4print("lookat",vm); Matrix output: lookat [ -0.902861 -0.036833 -0.428353 0...
This copies data from a project into Excel to be calculated into a final report. The code runs pretty slowly at this point and I would like it to be a little bit faster. Are there any blatant coding mishaps that are slowing the calculations down? Sub Update_Schedule() Dim appProj As MSProject.Application Dim aProg As M...
I have these two queries and they work just fine. I use the values they retrieve to populate a title for a view in my application. It seems though that I should be able to accomplish this with one query and I do not know how. Dim firstName = (From row In db.ItemDetails Where row.Unique_Location_ID = locationID An...
I've written a small app using the kivy framework, which aims at reviewing your times tables. My major concern is about making this app easier to improve in the future. That is, how to organize the code to make it more clearer (by adding a User class that would store the data associated to the user, for instance). Sinc...
I am working on improving the runtime of code that undistorts every pixel point in an image. Currently each point is undistorted via a call to cv::undistortPoints() as shown below: cv::Mat src(1, 1, CV_32FC2); // Create src and dst cv::Mat objects for cv::undistortPoints cv::Mat dst(1, 1, CV_32FC2); float* ptr...
I wrote a program to solve a magic numbers puzzle. The puzzle works like this: You have an NxN square where each row, column, and diagonals add up to x except some of the numbers in the square are switched. Find the numbers that are out of place and switch them. Here's an example: 16 16 11 09 14 17 09 29 13 ...
Here is the code I use to get the different weather forecasts from the Environment Canada website: public static void Main() { string url = "http://dd.weather.gc.ca/nowcasting/matrices/SCRIBE.NWCSTG." + DateTime.Now.ToString("MM.dd.HH") + "Z.n.Z"; string allStations = Decompress.zDecompress(url).ToString(); ...
I have a remote hosted server that's running Java VM with custom server code for a multiplayer real-time quiz game. The server deals with matchmaking, rooms, lobbies etc. I'm also using a MongoDB on same space which holds all the questions for the mobile phone quiz game. This is my first attempt at such a project and a...
I wanted to implement Java's Scanner in Scala. The goal for this class is to: Implement a Scala collection interface (probably Iterator[String]?) so I can access all the Scala collection goodies like map, .toList etc. Have better performance than java.util.Scanner Please review my code for bugs/design advice/performa...
The code below is the Index Action from a User Controllers. Basically this code returns a list of users from Azure Active Directory using Azure Authentication Library (ADAL). However I need to show 2 custom properties, in Azure AD, they are called Schema Extensions, they are just custom attributes where I saved custom...
I've been using this method to test file-system functions as an alternative to mock-fs due to its lack of symlink support. I'd love to hear what others think and the possible dangers, pitfalls, or improvements. var CWD = process.cwd() var assert = require('assert') var path = require('path') var os = require('os') var ...
I have to two datepickers. I want achieve the following functionality: the return date cannot be selected before the selected departure date and the departure date cannot be after the selected return date. Mainly I am interested in correctness of my angular architecture. I have moved datepicker into my custom directive...
I just started learning programming in the past two or three months. I started with Python, and now I'm learning lua. I started game programming this week and this is a game I made with the Love2D engine for lua. If you don't know how it works, there are these three main functions: love.load() -- Runs at game startup...
In my question to learn F#, I've decided to get one step closer to creating a programming language, and implement this simple Reverse Polish Notation "interpreter" of sorts. It does not allow for parentheses in input ( ), and only accepts expressions containing the following valid tokens: 0 1 2 3 4 5 6 7 8 9 + - * / H...
I have following Java class called TheNewMario. It reads a String path and iterates through the path from S to F. If the path is closed, we assume the runner can jump. The class returns the amount of steps it takes to get from S to F. I have added two path files. In the first example path, it works fine, but when the p...
I am restudying graph theories and I want to write a Graph class that would allow me to implement those methods. Is there a better way of implementing a general Graph class? Main function: int main() { using namespace GraphUtils; Graph<char> graph; Node<char> a('a'); Node<char> b('b'); Node<char...
The Goldbach Conjecture asserts that any even number over 2 will be the sum of exactly two prime numbers. I've created a function to find two prime numbers that add up to the number entered, but would like some help streamlining it and making it more robust. One thing I would like to add is the ability to find all pr...
This is a problem in CodeEval, moderate level. The problem is very easy for this level. But I am not able to get more than 60 points for any solution I submit. (Moderate levels highest score is 65 and they take speed and memory into consideration.) The problem statement is: There are two strings: A and B. Print 1 if s...
I'm working with a database that has typos in the values. To compensate for them I've made a function called standardizer() which removes spaces and converts all letters to uppercase. I do this so the value red in from the database can correctly be interpreted by the program. Also in values starting with the prefix 'sp...
MVC 5 doesn't seem to like JavaScript that much. I am creating link in JavaScript to a success method in my Ajax call. Razor: @Html.ActionLink("Amount", "Action", "Controller", new { id1 = "a", id2 ="b"}, new { target = "_blank"}) JavaScript: $('#element').html('<a href="' + '@Url.Action("Action", "Controller", new { ...
I am working on a KNN implementation for sparse datasets (that I apply to text analysis). My points are represented by a Dictionary<string, double>, each key represents a word of the text and the value, its count or TFIDF. I am using index inversion to reduce the number of distances to evaluate. However, evaluating th...
I had a task to realize ReadWriteMap public class ReadWriteMap implements Map { private HashMap map = new HashMap(); private ReadWriteLock readWriteLock = new ReentrantReadWriteLock(); private Lock readLock = readWriteLock.readLock(); private Lock writeLock = readWriteLock.writeLock(); @Override ...
I have created this code for both boolean and integer values to display a truth table for an "AND","OR","XOR", "NOT" gate. However I think that my code needs reviewing as it could be simplified. public class LogicalOpTable { public static void main(String[] args){ boolean p,q; System.out.println("...
I have the below code to list all tables which have columns DataAreaId and CountryRegionId. This works, but requires me to change the code in two places if I amend the column list (i.e. both the name in ('DataAreaId','CountryRegionId') code to list the required column names, and also the having COUNT(1) = 2 to match th...
Refer to the help message and title of this post for what the code does. I'm looking for tips on: Efficiency: While the find-and-replace approach I have works perfectly fine and does so in a relatively quick manner, it feels far slower than it could be. Idiomaticness: As always, I like writing code that abuses every f...
I have a procedure for conducting ANOVA, the details of which can be viewed in this white paper. I would like to be able to make the routine scalable to handle any number of groups. Below is the R code for a 2 group example. Any insights or comments are appreciated. Partial Moments: LPM<- function(degree,target,variab...
This code embeds a hyperlink into a cell of your choice of an Excel file. /** * @param pathName the path for the Excel file which you will update * @param string the string you want to put in the cell, and if you put an empty string, it will default to * "Empty String" * @param hyperlink the h...
What can be made better? How ugly is my code? If it's terrible, where can I improve? DECLARE @startDate char(8); DECLARE @endDate char(8); DECLARE @termStart char(12); DECLARE @Facility nvarchar(255); -- ************************** IMPORTANT ********************** -- SET THE START AND END DATES TO PULL DATA FOR THE DAT...
This just adds fractions. For example, if we have a text file with: 1/3 1/2 It will print: 5/6 I would love to hear some remarks on how I can make this more Scala-like. class Fraction(c: BigInt, d: BigInt) { val divisor = c.gcd(d); def counter = c / divisor; def denominator = d / divisor; def lcm(a: BigInt, ...
I use this in a self hosted web service, so I am not using a ton of libraries. I wanted a simple yet easy-to-use cookie repository. The reason the repository is static is that I wanted the ability to use the repository within Razor templates without having to use a reference object. I just find it simpler. I feel it's ...
Going through a book, I encountered the following assignment: Write an application that asks for the user’s first, middle, and last names and replies with the user’s initials. Are there any flaws you notice immediately? Is there any way this code can be improved? I'm not really interested in coding style (I guess s...
This is a classic memory game with a points counter for the two players. The app works fine, but since this is my first project in Swing, I would appreciate the critical opinion of some expert, as I'm sure there is plenty of space for code improvement/optimization. What do you think about the code? What should have I d...
Using Powershell, I've created a script to create a tree-view of a group/s' memberships in Active Directory. I originally had layers of nested loops, but I wanted a more algorithmic solution. The following code does the following: Get user input for: input source, depth-level int, output location Recursively find all ...
eWay has a simple Pay Now button that is embedded as a script. There are other ways to use the eWay API to take a custom payment, but they are slightly more complicated and the idea was to keep it simple. This is the basic script: <script src="https://secure.ewaypayments.com/ scripts/eCrypt.js" class="eway-payn...
I have been watching this video: https://www.youtube.com/watch?v=M6lYob8STMI And here is the code of it in groovy (just the add method): def addNode(k, v){ def newNode = new MNode(key: k, value: v) if(!root){ root = newNode }else{ MNode currentNode = root MNode parent w...
I have searched throughout the internet and found no OO approach to implement Weiler-Atherton algorithm, so I implemented the following. Please, help me to make the implementation more efficient and concise. #include <iostream> #include <vector> #include <cmath> //#include <graphics.h> #include <algorithm> using name...
I was given a this problem at a technical interview and failed miserably in the time given. Afterwards, I sat down and worked out what I think is a good solution. The task was actually to build an AngularJS app to do this, which I did, but the guts of my solution is in JavaScript. I wanted to ask if there is a better w...
There are multiple aspects in the code I do not really like. [card for card in ...] looks really lame, also [x.pop() for i in range(y)]. I'm looking forward for any recommendation. from random import shuffle class Deck(object): suits = range(4) ranks = range(13) @classmethod def generator(cls, suits,...
I have two arrays: $row $rowTwo The only difference between these two arrays are the first two keys have slightly different names due problems out of my control. I'm wondering if there is a cleaner way to do it. Or would it be simply easier to find a way to rename the arrays to match? $needUpdate = false; ...
I need to design and implement a service (C#, .Net 4.5+) which receives messages, converts the messages to BLL models and passes them to the BLL. Long story: The service will receive messages (strings containing multiple fields (no JSON, no XML just a string)) from a client. The format of the messages can change betw...
I had to write a generic wrapper that enables me to pass variable number of arguments for execution of some methods and repeat it up to a few times when it fails because of network connection problems. What I came up is this class and a helper method. Well I can't say it's perfect - it is sufficient for my need, but i...
I'm looking to do some basic verification testing on my functions that write to the filesystem. I took a hint from here on how to mock out the filesystem using an interface, but I'm kinda bummed on how the FileSystemOperations type needs to be passed along through every function. Any ideas how to improve this, or where...
After searching the internet, I was able to find a base JavaScript file in order to build upon for my project. Which is to create a Adobe Illustrator Script that will create the desired Folders and then export different resolution ratios for each artboard. This method is used in order to create Wallpapers of varying re...
I have a makefile that I've been using to compile my shared libraries which reads in the files from different folders and then builds the objects and binaries in their own folders. The folder structure I'm using roughly: -Folder | +--API Header Files Dir | +--Library (.so) Project One | +-- MakeFile Project One ...
This is the Java signum(double) method I am trying to imitate: public static double signum(double d) { return (d == 0.0 || Double.isNaN(d))?d:copySign(1.0, d); } This is my version public static double signum(double x) { return x != 0 ? x / abs(x) : 0; } I was thinking my method was not very readable, but I...
This function checks these 6 fields for a user profile to determine if they have "completed" their profile. This just feels like it could be done better, but I can't figure how. /** * Is the user's entire profile filled in? * * @return boolean */ public function isProfileComplete() { $checkList = [ $thi...
I have to create a 5x5 box using the images, and my first solution was to create 25 variables and print them, which is very inefficient. How can I optimize this? This utilizes cocos2d-x. auto cudrado0 = Sprite::create("images.png"); cudrado0->setPosition(Vec2(200, 200)); cudrado0->setScale(0.5); this->addChild(cudrado0...
I have implemented a symmetric (AES 128-bit) key diversification algorithm for Java following the NXP Notes. It works as expected but am not the best Java programmer around, I guess I have done quite a mess so I need help on how can improve the code and make it better? import java.io.ByteArrayOutputStream; import java....
I am implementing a multi-player game in C# and having seen all sorts of projects, from indie developers all the way to large studios struggle to patch networking into existing products in the past, have made the decision to get the networking aspect done first, and build the game on top of that. I've so far gotten to ...
The script scrapes a table from the website mentioned, looks at the last 2 columns, takes that information, and then sorts it (and then returns the largest county, and the set of races and their numbers). But, basically, I just wanted to know in which ways I can make this script parallel more closely with the Zen of Py...
First attempt at doing anything F#-y from a very heavy C# background, think I've grasped the fundamentals of FP, but always good to get other eyes on it: namespace FSharp.GameOfLife open System open System.Drawing module Array2D = let toArray (arr: 'T [,]) = arr |> Seq.cast<'T> |> Seq.toArray module Array = ...
I made myself a simple budgeting application. Each transaction is stored in the transactions table: CREATE TABLE transactions ( -- Foreign key into the "categories" table, not shown here. (In reality this -- has a NOT NULL constraint instead of a default, but this makes the -- example data easier to enter.)...
I'm relatively young in Java, and am familiar with only the basics of the language, yet. I've started studying data structures, and I've made an attempt to create a solution for the selection sort algorithm. After many attempts with errors and exceptions, I've managed to come up with what looks like a working solution....
I've created this simple 3D voxel terrain generator using Perlin Noise. I have a few concerns about it though. Is there any way to make it more performant? It currently takes ~1.5 seconds to generate a 200x200 map. Am I splitting up the different "jobs" of the generator correctly? Is my general code style good? usin...
I need to compute the max contiguous slice in an array. I wrote this function, but I am not sure if it is correct or I am missing edge cases. I ran several cases. def max_slice(a) max_start,max_end = 0,0 largest_sum = 0 curr_start,curr_end = 0,0 curr_sum = 0 for i in 0..a.length-1 if (curr_sum + a[i] < ...
I just began my C# debut and was just wondering if this Rock-Paper-Scissor console app is good and flexible. abstract class Participant //Abstract - no need for instances, Many common functionality { public int wins; float winRate; public void DisplayWinRate() { winRate = ((float)wins / Game_...
This is a password recovery program I made, and I just want it checked out. These aren't all the files for the login and register system, only the password recovery part. The columns in the users table are id, username, password, salt, passres, and passexp. passres is the reset token, and passexp is the expiration time...
I have Clips that can be added to or removed from any number of Lines. When I add the Clip, I put it into a ClipHolder so I can keep some bounds information with it which is specific to the Line / Clip relationship. The trouble comes when I want to remove a Clip from the Line. I need to remove the ClipHolder in the ass...
I have written a basic C Shell. It features the builtins cd, programmer, ver and exit. The code for the shell, named vsh, is as follows: #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <sys/wait.h> #define BUFSIZE 1024 #define TOK_BUFSIZE 64 #define TOK_DELIM " \t\r\n\a" char *...
I have created a game called 'runes' in C. It is similar to Chess, but has a bigger board and different pieces. I would like to know how I can improve the code, for example, by adding proper error checking and by fixing any bugs. (This is probably not called 'broken code' because the main functions work fine.) Also, th...
I have implemented the Dining Philosophers Problem in Clojure with refs, trying to emphasize readability. Please point out if parts of it are inefficient, not idiomatic, or improvable in any way. Full code on GitHub. ;;;;;;;;;;;;;;;;;;;; ;; DINING ;; ;; PHILOSOPHERS ;; ;; PROBLEM ;; ;;;;;;;;;;;;;;;;;;;...
All the test cases pass except one of the test case which runs > 10 seconds. What can I do to make my solution faster? def in_row(grid,i,k) grid[i].include? k end def in_col(grid,j,k) 0.upto(8) do |i| return true if grid[i][j] == k end false end def in_grid(grid,i,j,k) x,y =0,0 x = 3 if ...
While understanding the MVC pattern, I came across this particular article. I thought to implement it using the C++/QT library. The intent over here is to implement/use MVC concepts in correct way. Awaiting the feedback/review comments from community. model.h #ifndef MODEL_H #define MODEL_H class Model { public: Mo...
I am solving the following problem: You are given two lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a list. I wrote the following code: let addTwoNumbers (a: int list) (b: int list) = let rec...
I am prepping for a junior level interview in C#. I am hoping I can get some feedback on how to improve my code to print the most common occurrence of an int in an array. using System; using System.Collections; namespace FrequentInt { class MainClass { static void CommomOcurrence (int [] array, Hash...
I have a project where I'm to implement a DFS using a direct graph. The implementation should print the currently visited vertex, the parent (the node from which the current node was reached), and the discovery and finish time for each node. Using these graph values: int[] vertices = {1,2,3,4,5,6,7}; int[][] edges = {{...
I'm yrying to practice some OO PHP and I'm just wondering if what I'm doing is okay or not. Please tell me if there are any alarms in my method so that I can stop doing it and learn a better way. In my conditional statement, I was following the rule of no else keyword, based on this article by William Durand, which tal...
I am wanting to constantly check a URL http://www.example.co.uk/untitled.php which will either return 1 or 0 on my app. Is the most efficient way to do it by repeatedly requesting the URL every second like this? Function to return content of URL -(void)getOnline{ if(connected==0){ NSString *uuid = @"59xxxf...
I have created a game called Runes in C. It is similar to Chess, but has a bigger board and different pieces. I would like to know how I can improve the code, for example, with user interface improvements. This question is not a duplicate of that question, because this one has a revised and easier to read version of th...