instruction stringlengths 71 71.9k |
|---|
I am able to develop this matrix but I think code can be improved. I am creating a map on which each rectangle may have zero through many list items with their titles (still need to add code for adding titles):
var width = 600,
height = 600;
var margin = {top: -5, right: -5, bottom: -5, left: -5};
var zoom = d3.beha... |
The program should read equations from stdin, parse them and generate a matrix of the coefficient which represents the system.
Example:
$ ./eqs
x + y = 4
-y + 4x = 2
1 1 4
4 -1 2
As you can see, the user can input as many equations they want and the program stops reading when an empty line is sent.
#inclu... |
Find the sum of all the multiples of 3 or 5 below 1000.
https://projecteuler.net/problem=1
Is there any hack to do modulo operation in better way?
#include<iostream>
int main()
{
unsigned int sum=0;
for( int i = 0; i < 1000; ++i )
{
if( ( i % 3 == 0 ) || ( i % 5 == 0 ) ||
( ( i % 3 =... |
As part of the odin project I've written this bit of code that allows two users to play a game of Tic Tac Toe. I'm still a relative newbie to Ruby and to coding and am guessing that there are much better ways to do what I've done here. I'd love to get input, suggestions and recommendations.
The full code is below but ... |
I was practicing some C and decided to write this simple command line utility for stripping leading and trailing white-space characters.
Note: see the next iteration at A trivial command line utility for trimming whitespace from lines in C - follow-up
The code:
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
... |
I'm trying to review and figure the issues in the above code. Any inputs to point out problems are welcome.
using namespace std;
typedef basic_string<char> string;
class CHighLow
{
public:
CHighLow() : nCurLow(0), nCurHigh(0) {};
void add(int nHigh, int nLow)
{
if (nHigh > nCurHigh)
... |
Problem description:
A non-empty zero-indexed array A consisting of N integers is given. A pit in this array is any triplet of integers (P, Q, R) such that:
0 ≤ P < Q < R < N;
sequence [A[P], A[P+1], ..., A[Q]] is strictly decreasing, i.e. A[P] > A[P+1] > ... > A[Q];
sequence A[Q], A[Q+1], ..., A[R] is strictly increa... |
See the previous iteration: A trivial command line utility for trimming whitespace from lines in C
Note: see the next iteration at A trivial command line utility for trimming whitespace from lines in C - follow-up 2
Now my code looks like this:
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.... |
I have a list of error messages:
def errorMessages = ["Line : 1 Invoice does not foot Reported"
"Line : 2 Could not parse INVOICE_DATE value"
"Line 3 : Could not parse ADJUSTMENT_AMOUNT value"
"Line 4 : MATH ERROR"
"cl_id is a required ... |
I'm looking to pull all the youtube links from a string of text and was wondering how does this look?
if (preg_match_all('/(https?:\/\/)?(www\.)?(youtube\.com)\/watch\?v=([a-zA-Z0-9_-]+)[^\s]*/im', $this->content, $matches)) {
}
Obviously this doesn't take into account the youtu.be links as they are formatted differe... |
I am running a test load using Telerik Test Studio using 100 users at once entering search filters on a page that calls a stored procedure.
My application that calls the stored procedure is an ASP.NET MVC 5 application and it returns this error:
Timeout expired. The timeout period elapsed prior to completion of the op... |
This is my first attempt to a serious Node.js application, I've tried to follow the async style of Node at my best, but I have several doubts and I am sure that this code can be massively improved.
The idea behind this little service is to get a minified stacktrace and return a 'translated' stacktrace, if there is any ... |
I have a code snippet which I wish to improve to increase my program's FPS, but as a beginner in JavaScript, I do not know how. I know the problem, which is the fact my counter mechanism used to delay attacks is causing lag. I just don't know how to change my code to minimize this lag. I am looking for helpful criticis... |
The exercise 1.3 of the book Structure and Interpretation of Computer Programs asks the following:
Exercise 1.3. Define a procedure that takes three numbers as arguments and returns the sum of the squares of the two larger numbers.
My answer is this:
#![feature(core)]
use std::cmp;
fn sum_square_largest(x:f64, y:f6... |
The task was to build a simple parallel server in erlang that prints what it receives through a socket and alerts when the socket is closed.
-module(server).
-export([start/0]).
start() ->
{ok, ListenSocket} = gen_tcp:listen(8211,[binary,{packet,4},{active, once}]),
spawn(fun() -> accepter(ListenSocket) end),... |
I'm working on this small program for practice and would like to know how I could improve it from here. I'm still a relative beginner with C++ and would like to know if there is a better why to design this program.
Things I want to do:
Implement a while loop so that the program will continue to take input and write t... |
I have created a Library Management system. Can anyone please look at if see if there's any bad practices or if anything could be done better?
Main.cpp
#include <stdlib.h>
#include <iostream>
#include <fstream>
#include<iomanip>
#include<stdio.h>
#include <string.h>
#include "Book.h"
#include "DVD.h"
#include "Student.... |
I'm extremely amateur when it comes to C++ in general, but I wanted to make a little "Pyramid Escape" text based game. I'm not done whatsoever but before I continue I want to see what I could possible do differently.
//
// main.cpp
// TextFiles
//
// Created by Neal Carico on 3/12/15.
// Copyright (c) 2015 Nedev. ... |
This code finds expectation and standard deviation of sum(x) of 6 digited base-49 numbers with all digits distinct.
The expectation is: \$\mu={\rm E[X]}=\frac1n\sum_{k=0}^{n}x_i=\frac{x_1+x_2+\ldots+x_n}{n}\$ whereas standard deviation is: \${\rm \sigma[X]}=\sqrt{{\rm E[(X-\mu)^2]}}=\sqrt{\frac1n[(x_1-\mu)^2+(x_2-\mu... |
I wrote a sub to remove the blank entries in a row without shifting the cells around but it seems unnecessarily clunky and I'd like to get some advice on how to improve it.
Public Sub removeBlankEntriesFromRow(inputRow As Range, pasteLocation As String)
'Removes blank entries from inputRow and pastes the result int... |
I have a set of API endpoints where the URL is not standardized, so I could either get "api/auth" or "api/auth/" (may or may not end with "/"). I'm 'registering' the endpoint, plus the HTTP Method that comes in, so I can exclude certain endpoints from having to authenticate.
I've written this piece of code, which has a... |
I'm just learning Haskell and I wanted to know if I'm going in the right direction with my solving of the Haskell 99 problems. The file of interest is here which I've also reproduced below.
module OneToTen where
{-- Problem 1: Find the last element of a list. --}
myLast :: [a] -> a
myLast [] = error "Empty list."
myL... |
Problem statement
The Utopian tree goes through 2 cycles of growth every year. The first
growth cycle occurs during the monsoon, when it doubles in height. The
second growth cycle occurs during the summer, when its height
increases by 1 meter. Now, a new Utopian tree sapling is planted at
the onset of the mon... |
I'm a Java beginner, going through the Generics Questions and Exercises in Oracle's The Java Tutorials.
Here's my solution to #8:
Write a generic method to find the maximal element in the range [begin, end] of a list.
All suggestions for improvement are welcome. I'd especially like feedback on the following:
Java li... |
I've got a filter that I'd like to work out how to optimize. The most basic implementation, using loops is like the following:
import numpy as np
nrow = 500
ncol = 500
refArray = np.random.randint( 0,100, (nrow,ncol) )
boundsArray = np.random.randint( 90,95, (2,nrow,ncol) )
window = 31
halfwindow = window/2
result = np... |
I wrote a script that reads a file containing a password ("password"), loops each character in that file to see if it matches a character in the alphabet, and when every letter has been found the password is printed.
def readFile():
file = raw_input("Enter file that contains the password: ");
file = open(file, ... |
This Python 3.4 script downloads stock data and puts it into an Excel file.
## Imports/Initiation
# Put a "#" in front of the one you don't want to use.
signs = 'a abc abt ace acn act adbe adi aet afl agn agu aig all alxn amgn amt amzn apa apc apd axp azo ba bac bam bax bbby bdx ben bfb bhi bhp biib bmy bp brk-b bud ... |
I developed a script for the company I work for in order to extract data from SAP (CJ74) and analyze the data.
One particular issue I am finding is that for any data sets which have over 1000 lines, it struggles to execute the section of code below, therefore I am searching for answers.
This code takes free hand text... |
I have a big log file (say 1-3 Gb) which I need to parse, extract data & save it in a CSV file.
Text File Data
* D:40035FC8 wr-long 00000008 \\core0\Global\u4TimeHiCnt 1.000us
* D:40027C5C rd-byte 00 *core0\Global\Ypf_OILL_OilLvlOn 20.342us
* D:40010044 rd-word ... |
What is Coupon Collector's Problem?
In probability theory, the coupon collector's problem describes the "collect all coupons and win" contests. It asks the following question: Suppose that there is an urn of n different coupons, from which coupons are being collected, equally likely, with replacement. What is the prob... |
For some time it has been bothering me that there is apparently no way to directly initialize variables from input streams (something like int i << std::cin;)
My solution is this:
#include <iostream>
#include <iomanip>
#include <string>
template<class T>
T get(std::istream& in){
T tmp;
in >> tmp;
return tm... |
In this constructor function I'm assigning everything to the proper variables. For the third parameter it accepts an options argument that contains the optional settings.
To prevent a Cannot read property x of undefined. error I'm always checking this variable by steps, since the options variable can contain both compl... |
This question is a continuation of my previous question:
Check is_permutation on a pair of same sized arrays.
I improved the implementation to generalize for all sequence containers. Please let me know how I can improve this implementation again.
#include<iostream>
#include<algorithm>
#include<unordered_map>
#include<a... |
I am working on an AB tool in JavaScript using the following:
Calculate the Conversion rate based on the conversions divided by the hits.
Calculate the Z Score by passing in the control and treatment objects.
Determine the confidence of the Z Score with Cumulative Normal Distribution.
How accurate is this?
/**
Exam... |
I am writing a system for doctors who are regularly visited by patients. The doctor adds each patient's visit to collection/database. The class can save data to an .xml file and restore it. Can you give your feedback about this code?
// https://github.com/veitsi/jcrf-noweb
import java.util.ArrayList;
import java.util.... |
Being pretty new to testing, I was wondering how many of these tests make sense.
restaurants_controller_spec.rb
require 'spec_helper'
describe RestaurantsController do
describe "GET #index" do
before(:each) { get :index }
let(:restaurants) { create_list :restaurant, 5 }
it "populates @restaurants" do
... |
I am new to Azure and SQL. I have the following function that is part of a larger Web-API which is hosted on Azure and is querying an SQL Server database that is also hosted on the Azure platform:
[WebMethod]
public string RetrieveUserFriends(string userId)
{
//Ensure there is a user id
if (userId == null)
... |
For this assignment, you will create the pattern of a chess board that
is 8 x 8. Use X and O to represent the squares.
Create the appropriate nested looping structure to output the characters in an 8 x 8 grid on the screen using Console.Write() or
Console.WriteLine() as appropriate.
Include a decision structure ... |
I am fairly new to the Groovy arena. I recently modified some code to add the following block. This code is added to remove dates we were supposed to remove from the total counts. This data goes on reports that a bug was noticed, that we weren't removing the queue entry dates.
result.processed.each{
def queueEntry... |
I am implementing an automated help function in my code. It is simply a few bubbles that pop up with some text in them. I use d3 to select one bubble, display it for a short time, and then select another bubble and display that one. It works, but I don't like the shape the code is taking. Am I approaching this correctl... |
I have been working on a project to randomly generate a torus made through the use of an adjacency list and disjoint set structure (to be extended to solve the maze later), made from scratch. I think that I have optimized my code pretty well, but may have over-looked some things.
Program Description:
The program works ... |
I have attempted doing a fluent API for creating random int arrays, and the following is what I came up with:
fluent_arrays.h:
#ifndef FLUENT_ARRAYS_H
#define FLUENT_ARRAYS_H
#define REQUEST_THREAD_LOCAL 1
#ifdef REQUEST_THREAD_LOCAL
#define THREAD_LOCAL __thread
#else
#define THREAD_LOCAL
#endif
/*****************... |
I am playing with Rust, and am trying to write a simple parser.
I need to parse the string:
"0123,456789"
into a stucture:
Passport { label : i8 = 0, body : i32 = 123456789 }
I am using parser_combinators and my code is working, but very ugly.
How can I rewrite this code?
extern crate parser_combinators as pc;
use ... |
So I'm trying to code a navigation scroll bar like that looks like this:
This is the code:
<!DOCTYPE html>
<html>
<head>
<style>
ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
}
li {
float: left;
}
a:link, a:visited {
display: block;
width: 120px;
height: 50px;
... |
I'm trying to write a simplistic Monte Carlo simulator to predict asset prices. For example, if something has an initial value of 50 and an historic daily standard deviation of 2, what are the odds it will be 40, 40-50, 50-60 or greater than 60 in 25 days?
import random
start = 50
sd = 2
days = 25
bins = [40,50,60]
i... |
I’ve written an answer for The Grid Search challenge on HackerRank.
Please let me know of any improvements that can be made to my implementation (specifically if there's any way to make the algorithm more efficient. I'd like to make this algorithm optimal).
P.S: My implementation is a brute force algorithm, and I reck... |
I tried to implement an immutable list.
public class ImmutableList<T> : IEnumerable<T>
{
public T Head { get; set; }
public ImmutableList<T> Tail { get; set; }
protected ImmutableList()
{
}
public static ImmutableList<T> WithItems(IEnumerable<T> items)
{
if (items.Count() == 1)
... |
The program adds two binary numbers in two' s complement ignoring the overflow for a constant size of bits. I am trying to generalize the program by taking input from the user in a single line without memory wastage. Is there any way to achieve this?
#include<iostream.h>
#include<conio.h>
void main ()
{
const int ... |
I am going through the CodingBat exercises for Java. I got to this problem:
Return a version of the given string, where for every star (*) in the string the star and the chars immediately to its left and right (if any) are gone. So "ad", "ab*cd", "ab**cd", "*ead", and "ade*" all yield "ad".
I decided to solve this u... |
As I am a totally self-taught 'person writing code', I decided to learn algorithms with one online course that taught them using Java for demonstrative purposes. The first topic I covered is the graph data structure and API.
I undertook to rewrite Java examples into PHP for training purposes. I would be really grateful... |
I am working through the Coding Bat exercises for Java. Here is one I have just completed:
Given a string and a non-empty word string, return a version of the original String where all chars have been replaced by pluses ("+"), except for appearances of the word string which are preserved unchanged.
And here is my sol... |
Goal: create a new OrderedDict instance's keys in such way that keys in the specified order list appear first. If some keys in order list are not present in OrderedDict, ignore them.
Additionally, reordering should be "stable", that is, if some keys were not specified in order list, they should keep their original ord... |
How can I do this better?
$a = "Tom Smith" ; $e = $a.substring(0,1)
$ee = ($a).split(" "); $y = $e + $ee[1]; $y
TSmith
|
Here is the source of the question, and my solution is below.
Did I determine the worst case correctly?
If you find any input where it doesn't work, please let me know.
public class Main {
/*
* http://www.careercup.com/question?id=6305076727513088
*
* Worst case: O(2*n)
* [ 1, 3, 4, 1, 0, 23 ]... |
I have here some code which is working but it seems to be a lot of coding to do here. I would really appreciate if someone could make this simpler.
<!-- *********************************************** -->
<div class="widget search-w">
<div class="wrapper">
<div class="big-icon search icontap"><a class="widg... |
A code challenge between some friends, as I came from a Procedural way of coding, instead of using Objects. The paramaters are below:
store the properties of a car
colour
make
model
speed
direction
demonstrate how these properties are accessed
manipulate these properties through standard calls (functions/methods)... |
This was a little app I wrote looking for a way to create consistency in the way employees taking phone orders enter the address.
The purpose of the app is to require a user to enter a valid address.
The scope broadened to include two secondary objectives, performance and proper rendering.
Performance: No IF ELSE o... |
I am writing a stop watch utility class in Java that I want to be thread-safe (concurrent). Here is what I have right now:
public class Stopwatch {
private volatile long beginTime;
private final AtomicLong lastLap = new AtomicLong();
private final AtomicReference<List<Long>> laps = new AtomicReference<Lis... |
I need to perform few tasks inside a Windows Service I am writing in parallel. I am using VS2013, .NET 4.5 and this post shows that TPL is the way to go.
I was wondering if anyone can tell me if I have done it correctly.
public partial class FtpLink : ServiceBase
{
private readonly CancellationTokenSource _cancella... |
I have written a small plugin library for CKFinder that I would like some critiques on.
The library is located here.
If you are looking for where to start, check out plugin.php and hook function in here in the assets/ckfinder/core/connector/php/php5/CommandHandler/ folder.
I would really love to hear your critiques on:... |
I've developed as part of a game engine a template class for a factory which manages objects of one specific type. The factory handles initialization, destruction, and accessing previously created objects by string identifier.
It allows forwarding parameters to object constructors with variadic arguments, and is interf... |
I am new to Python. I wrote a code that works but the algorithm is obviously not efficient at all. I am stuck in the loop on iterrows and I do not see how to get rid of it.
First a little bit on the data, they look like that:
var1 var2 var3 var4 var5 var6 var7 var8 var9 var10 var11 var12 var13 var14 var15 var16 n
... |
I would like to get a distinct array of objects. The code below is the first thing that came to mind.
Do you see any room for improvements?
function distinct(objectArray){
var distinctResult = [];
$.each(objectArray, function(i, currentObject){
if(!exists(distinctResult, currentObject))
... |
I've been looking for a way to have a predicate that establishes that all elements of a list are substrings delimited by a given string. Analogues in other languages include: 'delimiter'.join(list) in Python, (mapconcat function sequence delimiter) in Emacs Lisp, array.join('delimiter') in JavaScript, and I'm sure ther... |
For a while, I have tried to find ways (known or new) to do stuff with Gray codes. As some of you probably know, I already tried to implement an algorithm to add two Gray codes without having to convert them to a regular binary representation, perform a regular addition and convert the result back to a Gray code.
The f... |
The previous iteration at A trivial command line utility for trimming whitespace from lines in C - follow-up
Note: the next iteration at A trivial command line utility for trimming whitespace from lines in C - follow-up 3
Now my code looks like:
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string... |
It has been very hard to use recursion, but I think that it made the code shorter and cleaner.
import doctest
import operator as op
START_FOR_SYMBOLS = {'+': 0,
'*': 1,
'/':1,
'-':0
}
OP_FOR_SYMBOL = {'+': op.add,
'*'... |
I have the following CSS:
.class {
margin: 1%;
margin-left: 0;
}
I wonder whether another way would be better?
Option a)
.class {
margin: 1% 1% 1% 0;
}
Option b)
.class {
margin-top: 1%;
margin-bottom: 1%;
margin-right: 1%;
}
Option ...
Any other recommended ways?
|
I wrote perfectly working code that reads an image, and then does a kind of threshold on it by zone. If the zone has too much white then it turns all the zone into white, otherwise it turns into black.
The problem is that the code was originally from a C++ source with pointers and all instead of GetPixel() etc. Speed w... |
I created this responsive jQuery navigation which will re-size when the pixels get < 500 px and display the mobile navigation, although when the browser resizes > 500px it runs the widthCheck() function which is supposed to run the jQuery code that returns it to tablet/desktop size, although it doesn't do this transiti... |
I have a basic version of CGoL running with pdCurses. My goal was to have each newly spawned cell take on the dominant color of their neighbors (if a spawned cell is mostly surrounded by red, make it red). I managed to get a half-baked solution working, but it has a few problems, mainly:
It requires another member vec... |
I have a method in my Ruby code that sets the default name for my model. Rubocop complains that Assignment Branch Condition Size is too high, 21.24/15. How can I improve this?
def set_default_display_name
return unless display_name.blank?
count = user.credentials.where(type: type).count
if count == 0
self... |
For fun, I've made a practical file IO class in C++ with the purpose of being light and quick, and extendable for custom parsers. Here is the code:
parser.h
//
// parser.h
//
// Created by Taylor Shuler on 4/8/15.
//
//
#ifndef _parser
#define _parser
#include <fstream>
#include <iostream>
#include <list>
#include... |
Given a number \$t\$, (\$1 \leq t \leq 1000\$) that represent
testcases and \$t\$ numbers \$n\$ (\$1 \leq n \leq 10^9\$). Show the
next multiple of \$n\$ that is a perfect square number.
Example of input:
5
5 9 10 12 13
Example of output:
Case #1: 25
Case #2: 9
Case #3: 100
Case #4: 36
Case #5: 169
My solut... |
I've written an implementation for the Sherlock GCD HackerRank Challenge. As the running time of my algorithm is something like \$O(kn^2)\$, I reckon that there's a more efficient algorithm that could be used instead. Are there any improvements that can be made to my implementation to reduce the running time?
Problem s... |
I've written a function (in Python 3) which computes if a line segment (constraint) and a circle (body) collide, and returns the point of intersection (closest point to the centre of the circle):
def constraintCollide(self, constraint):
p1 = constraint.point1 # Sets the first point object of the constraint to p1
... |
As I'm getting to grips with front end development I'm looking to consolidate/improve my below HTML, CSS and JS code in terms of adhering to best practices so any advice is appreciated.
Quick overview:
I'm working on a page which has required me to create a page with a nav bar, a horizontal bar below the nav bar, a ver... |
I built this simple slider with JS, but I am not so experienced with programming and I wonder what can be improved in this code, how to dry it, or how to apply some OOP paradigms to it, what is not good in it, what is bad practice... If you are going to build this simple slider how would you approach it?
JSFIDDLE
HTML... |
I am going through the CodingBat exercises for Java. I have just completed this one:
Given two strings, base and remove, return a version of the base string where all instances of the remove string have been removed (not case sensitive). You may assume that the remove string is length 1 or more. Remove only non-overla... |
I'm currently faced with a problem in our SQL Server environments. We need to migrate our existing logins, users and roles to a new login, user and role with the same permissions as the old. I've been tasked with writing a stored procedure that will accept 3 parameters:
Database Name
Old Role
New Role
Using these par... |
I need to get folder names with the path for which I need to search the directory in a server with about 6000 folders. I have the following snippet of code to run through the folder and get the folder names with path. It works fine in a local directory but when I run the same code on a server directory it fails after a... |
I was recently given a coding test by an employer. After the test, this was the employer's response:
"I’d say that a lot of his solutions were pretty inefficient and took
a very ‘brute force’ approach to a solution. For example, his solution
for question 1 took 30 lines (give or take for some spacing). This is
... |
Presenting you an implementation of the "shear and transpose" method of rotating a bitmap image. It works.. but it works slow, which is fully understandable. It is understandable due to the evident lack of optimization. Notwithstanding it doesn't interact with the VGA or any library for that matter.
#include <stdio.h>... |
I'm currently enrolled in an introductory C#/.Net 4.5 course and one of the things I want to focus on is the quality of my code.
This is the first assignment our instructor had us do, the ever-popular number guessing game. The requirements our instructor set out for us were:
On startup, the program asks the user to s... |
I think I put too much code in my controller that was supposed to go in the model.
This is a part of my controller, I'm not gonna paste everything since there is a lot of code.
public function ajaxUsers() {
if($_GET["action"] == "listUsers") {
if(!isset($_POST["search"])) {
$this->_data['Reco... |
I recently ran in to a problem with the presentation of data related to a graph. Each series of data has values that define the 'curve'. There can be a lot of these values, and I decided that there was not enough space in the 'legend' to include all the details for the curve. I decided to have a 'details' area, and use... |
I've updated my code according to some tips from a previous post and would like to post the new code for review.
// Calculates and generates a report card of students final grades
#include <iostream>
#include <fstream>
#include <string>
float assignWeight;
float midtermWeight;
float finalWeight;
float participationW... |
I've written a small C program that has ad hoc implementation of cruise control for my Altera DE2 FPGA. It works alright but there are too many global variables. Preferably there should be no global variables. How can I reduce the amount of global variables?
#include <stdio.h>
#include "system.h"
#include "includes.h"
... |
An Entity Component System works by grouping various components around a central ID, aka Entity. Entities and Components do not have any code, they are simply POD containers. Rather, the code lies in a system, which takes in a group of components and does work on them. I've written out an EntityManager class and a temp... |
This is a follow on to : Simplifying asynchronous "executeAsync" method along with "onFailure" callback.
I am using AsyncRestTemplate as my HttpClient to execute my URL and the server will return back a json string as the response. Customer will call this library by passing DataKey object which has userId in it.
Given... |
I've made a small "rover game" similar to this one, except made in C#, using OOP, and prettier menus. Here's how it works:
There is one Rover class which is instantiated into an array containing all rovers. This class contains certain actions that a rover might need like, MoveRover, or RoverDead. There is also a RoverM... |
Recently, I was taking up this challenge and choose my favorite language 'Ruby' to do it.
My following solution got accepted (Gist).
For each test case, I am to reverse two numbers, add them, and print the reverse of the sum. Reversing means taking the base-10 digits of a number in reverse order, stripping any leading... |
The previous iteration at A trivial command line utility for trimming whitespace from lines in C - follow-up 2
Now my code looks like:
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#define HELP_FLAG "-h"
#define VERSION_FLAG "-v"
#define FLAG_DESC ... |
I am working on a project that involves scheduling real world events for a pool. Example: turn a pump on at 8AM, turn heater on at 9 AM, set heating temperature to 80 degrees, turn the pump off at 10 AM, etc. Events can be inserted into the queue in order by time and be popped off and processed at a later time. I also ... |
The following query returns the latest Odds for each Offer based on the timestamp on the Odds. However, the query takes an average of 1497ms - and I'm sincerely asking for help to optimize it.
SELECT DISTINCT ON ("odds_odds"."offer_id")
"odds_odds"."id", "odds_odds"."o1", "odds_odds"."o2", "odds_odds"."o3", "odds_o... |
Note: the next iteration at Natural merge sort - follow-up
I have compiled natural merge sort algorithm from Java to C++.
Natural merge sort sacrifices at most \$2N\$ amount of work in order to recognize the runs in the input range. A run is a contiguous subsequence which is ascending or strictly descending. Every desc... |
A contestant is said to be a winner if his number is strictly greater than the numbers to his left and his right and a contestant is said to be a loser if his number is strictly less than the numbers to his left and right so the contestant are on a circle and I should calculate the number of winners and losers.
Please ... |
I would like to speed up this piece of code. The macro gets a search variable from the worksheet "RAW_DATA_ARCHIVE" and then it should find it in the worksheet "RAW DATA". When it finds accordance then the value of column A from worksheet "RAW DATA" will be written in the last column of "RAW_DATA_ARCHIVE".
For i = 2 T... |
I am studying JavaEE and I have made my project for the learning experience.
I want to understand how best to write code from the point of view of architecture and use of relevant technologies. I am particularly interested to hear about the implementation of the REST-layer.
The purpose of this is the backend to the An... |
I'm looking for some feedback on my first program. It's a small game you play with matches.
It's a two-player game, where the players take turns picking matches (1, 2 or 3) and cannot pick the same number of matches as the other player: if player one picks 2 matches, player two will have to pick either 1 or 3 matches. ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.