instruction stringlengths 71 71.9k |
|---|
I'm using QScintilla in my project. There's no good FindQScintilla.cmake out there, so I'm writing one myself. However, I don't really know what I'm doing. This is my attempt; it works, but I don't know how it'll work in reality:
find_path(QSCINTILLA_INCLUDE_DIR
NAMES Qsci qsciglobal.h
PATHS "${Qt5Core_INCLUDE_D... |
After reading about the Shunting-yard algorithm, I decided to try to make a expression parser, before trying to make a actual language parser, using it. The way i translated the algorithm into C++ code seems pretty compact, so there is really not much code to post:
Shunting-yard algorithm(in C++):
#include <iostream>
... |
I am writing a subroutine for unsigned integer division in Assembly. I will call the subroutine DIVU.
Inputs: R1 will be the dividend. The divisor will be in R0.
Outputs: The quotient is going to be in RO and the remained in R1.
Basically, I am trying to make something like this:
R1 / R0 = R0remainderR1
If R0=0, I wan... |
This is a follow up to my last code review:
URLify a string using Python
This problem has been reviewed in other languages, but I tried to solve this without looking at those answers.
I am hoping that I achieved \$O(n)\$ time and \$O(1)\$ space as was explained in my last review. I would also appreciate any tips on im... |
I'm currently working with Win32 and OpenGL a little bit and I needed a way to get the pointers of the OpenGL functions that aren't included in the Windows gl/GL.h header file. Rather than spending hours going through the OpenGL specification and manually typing out each OpenGL function definition in a header file, I c... |
I have many (4000+) CSVs of stock data (Date, Open, High, Low, Close) which I import into individual Pandas dataframes to perform analysis. I am new to Python and want to calculate a rolling 12month beta for each stock, I found a post to calculate rolling beta (Python pandas calculate rolling stock beta using rolling a... |
I'm new to jQuery, but I have a fair bit of experience with JavaScript, mainly using Angular.
What I'm wanting to do is have implement a horizontal list of tabs, where clicking each button will display a corresponding div, and hide the others.
Here's how I'm doing it:
$(document).ready(function(){
$(".tab-group").... |
Project now on Github: https://github.com/IanCaio/TempI
I just finished a working version of a small Unity indicator in C, that is supposed to take the output of the application "sensors" (sudo apt-get install sensors required) and uses it to monitor the temperature of the CPU.
It creates one indicator that has a small... |
This code implements quick sort and takes advantage of passing the list by reference. I'm looking for performance and general best practices.
import random
def quicksort(array, l=0, r=-1):
# array is list to sort, array is going to be passed by reference, this is new to me, try not to suck
# l is the left boun... |
Here's is the code I'd like reviewed:
module Main where
import Control.Monad ( when )
import System.Exit ( exitSuccess )
import Idris.AbsSyntax
import Idris.Error
import Idris.CmdOptions
import Idris.Info
import Idris.Info.Show
import Idris.Package
import Idris.Main
import Util.System ( setupBundledCC )
processShow... |
I got an idea to make a Roman/Arabic number converter, and I would like to hear your thoughts, where I could improve it, if there are Python specific things that I missed, so on and so forth.
# Decodes roman numerals
def get_arabic_numbers(t):
# Hold the numbers in the list
l = list()
# The format
form... |
This is the first of (hopefully) several posts as I reimplement an ancient (and unfortunately long lost) Excel VBA Tetris clone. The main workhorse class in the game engine is the display driver, which uses a rectangular area of a Worksheet to emulate a monitor. The display is sprite based, so the class holds a Dictio... |
I recently asked this question on Stack Overflow, but now that I have a working example, I would like to have it checked.
I set up the layout like this:
I am going off the idea that parents can talk directly to their children, but children should use an interface to talk to parents (docs). The docs where not clear, th... |
I wrote a password manager with the goal of being able to recover your passwords without connecting to an external resource. I used Electrum's recoverable bitcoin wallet for inspiration. When you create a profile in the password manager, a random 12 word phrase is generated, hashed, encrypted with the profile password ... |
I have this code which first checks for blank cell in Column B, and then blank cells in Column F. If the results is Yes-No, then it prints the phonetic into F.
Can someone review the code, please? I am also wondering if there is a way to set the starting point to be Column B (therefore, Cells(i,1)=B1) and possibility r... |
I wrote a simple online logistic regression, calibrated using gradient descent to compare the speed of an OCaml implementation vs the same Python script, executed with Pypy. It turned out that the OCaml implementation was slightly faster than the one run with Pypy (by about 10%). Now I would like to optimize my code ev... |
This is my solution to my SO question. My requirements are:
use links inside of the angular app
when following a link with the same path (i.e., differing in the search only), do not add it to the browser history
.run(function($rootScope, $location) {
var replacing;
$rootScope.$on("$locationChangeStart", fu... |
I made this game which should imitate a spaceship and obstacles (planets). Move spaceship and try to hit everything.
I will add some others features and functionality (better images or whatever).
I have several question.
My IDE (IntelliJ) gives me some warning and I try to remove them. One of them is "access can be pac... |
Originally I had ChildUserControl inside ParentUserControl inside MainWindow with this view-models (here only constructors):
public MainViewModel(IParentViewModel pvm) {}
public ParentViewModel(IChildViewModel cvm) {}
public ChildViewModel(IMessenger m) {}
And straightforward DI initialization in ViewModelLocator:
v... |
So I am trying to write, essentially from a blank slate, a program that plays Grand Chess. In short, it is a chess variant that is played with two extra pieces, on a 10x10 board, no castling, and optional promotion on the 8th and 9th ranks, mandatory on the last. Finally, you may not promote to a piece unless it has be... |
I'd like to create a function that can concatenate vectors or strings. It must
Keep correct order
Be optimal
This is the solution I came up with:
template<typename V>
V concatenate( V&& v )
{
return v;
}
template<typename V1, typename V2, typename... Rest>
V1 concatenate( V1 v1, V2&& v2, Rest&&... rest)
{
v1.ins... |
I'm using this class for producer-consumer setup in C++:
#pragma once
#include <queue>
#include <mutex>
#include <condition_variable>
#include <memory>
#include <atomic>
template <typename T> class SafeQueue
{
public:
SafeQueue() :
_shutdown(false)
{
}
void Enqueue(T item)
{
std::uni... |
I have a spreed sheet and its something like 550+ columns and I need to pull URLs from it. Previously I was using LinqToExcel when the sheet was less than 255 columns a recent update has produced this monstrosity, so I have moved on to interop with excel to parse the data.
Needless to say I have a list of a string I w... |
I currently have this code to generate a discrete signal with random amplitudes, but a fixed frequency:
import matplotlib.pyplot as plt
import numpy as np
# constants
t_len = 0.5
freq = 10.0
dt = 0.001
# set the see for reproducible results
rng = np.random.RandomState(0)
# create the random values to interpolate bet... |
Like most of the folks here, I'm learning Haskell, so I figured an interesting exercise would be to build a matching engine that I could use to build a financial exchange. I'm wondering primarily if I used monad transformers here idiomatically, but all other feedback is appreciated as well.
In some cases I felt like us... |
A \$Z^m\$ number system includes integers in the interval \$[0, m)\$ when \$m > 0\$ or \$(m, 0]\$ when \$m < 0\$. The code defines a trait Mod to represent numbers in this system and the +, -, and * operator for it.
use std::ops::Add;
use std::ops::Mul;
use std::ops::Sub;
struct Mod<T: Modulo<T>> {
modulo: T,
... |
Is there a way I could somehow have all this classes condensed into one, while keeping the code as clean as possible?
They are all doing essentially the same thing, just for the different number type. I don't know how to "generalize" TryParse() without using switch or if tree which doesn't seem very clean to me.
Base c... |
The purpose of this code to is check the 3 float switches in the laminator chamber for water. The float switches vote with the majority winning. A momentary switch must be pressed for the section of code (//// START FILL LAMINATOR FROM 70GALLON RES ///) to be active.
We can also take water from the reservoir using a di... |
I created this program as an exercise for me to learn ruby. It is a random name generator with a set of rules defined to generate pretty decent and usually pronouncable names. Ruby isn't exactly my favourite language, but I needed to learn it. The names produced consist of both latin letters and a few non-latin symbols... |
A \$Z^m\$ number system includes integers in the interval \$[0, m)\$ when \$m > 0\$ or \$(m, 0]\$ when \$m < 0\$. The code defines a trait Mod to represent numbers in this system and the +, -, and * operator for it.
use std::ops::Add;
use std::ops::Mul;
use std::ops::Sub;
use std::ops::Rem;
struct Mod<T>
where T... |
I am looking for assistance with the code at the last section referenced as "Logic to calculate allocation". I'm looking to conduct various SumIfs divided by CountIfs for a range cells that span about 30k rows and over 20 columns. I've tested it for just one column and it provided the results I expected but the time wa... |
After some advice, which method do you think is better to use when searching a dictionary for the matching value(s)?
Method One
Console.WriteLine("ENTER A PERSON/NUMBER TO SEARCH FOR");
string input = Console.ReadLine().ToUpper();
bool found = false;
if (myPhoneBook.ContainsKey(input)) // used with a persons name and ... |
I was looking for a way to navigate through a dataframe in R using just the console that displays every n lines. There are a few functions you can find at StackOverflow that attempt to answer this but none are quite what I want. So I made my own function but it has a lot of if statements. How can I refactor my code to ... |
I have a wrapper class:
[Serializable]
// (465 references)
public class Value<T>
{
private T value;
[NonSerialized]
private List<IValueListener<T>> listeners = new List<IValueListener<T>>();
// (232 references)
public Value(T value)
{
this.value = value;
}
// (274 references)
... |
My second attempt with vb.net - I tried taking the advice from yesterday's question into consideration, but I did not try using LINQ.
You know the drill:
A programming challenge that prints the numbers from 1 to 100, where
multiples of three print "Fizz," multiples of five print "Buzz," and
multiples of both three... |
I have implemented a thread safe filtering queue. The queue allows any objects, of the specified type to be added. A thread interested to take an object must specify which object it is interested in via Predicate<T>. A particularity of this implementation is that in my use case, the threads might not be allowed to remo... |
This is just for fun so you will see tons of print statements for trouble shooting. I was hoping on slimming this down some and gain new ideas on what I have. This was a challenge question in a class I'm not in. I know the code i wrote is nightmare-ish anything to slim it down would be nice.
import java.util.*;
publ... |
In one of my applications I make requests to a server. However, that server may at some point start making requests to my application as well. The server also allows polling, this means that I am able to make a request to a URL on the server and it only returns after some time if it does not have any content available ... |
At the moment, I'm trying to get some experience writing C++, Win32 and OpenGL, so I decided to implement a "Hello World" of sorts. However, instead of printing Hello World! to the console, I render a colorful triangle.
#include <Windows.h>
#include <gl/GL.h>
#include <gl/GLU.h>
#include <gl/glext.h>
#include <gl/wglex... |
This is a solution to exercise 1.4 from Cracking the Coding Interview written using Python 3.
Given a string, write a function to check if it is a permutation of a palindrome.
Example: 'Tact Coa'
Output: True (permutations: "taco cat", "atco cta", etc.)
I wanted to get feedback on making my code clearer and more pyth... |
Here's a PHP PDO wrapper class that I wrote, along with example usage. This class features 2 primary methods for interacting with a database: Query(), which returns a result set, and Execute(), which doesn't. The class and its public methods are PascalCase, protected/private properties and methods camelCase. I am inter... |
I'd originally not copied the result vector to vec which I figured and corrected. Iis there a better way to implement the merge sort other than the approach I've taken?
template<typename T> void merge(std::vector<T> &vec, int left, int mid, int right )
{
int i=left;
int j=mid+1;
int k=0;
int size = (rig... |
I am new to Haskell, and have been reading Learn You a Haskell for Great Good!.
I've rewritten a problem that I recently solved in JavaScript in Haskell to practice what I have been reading.
A little bit of a back story with out rambling on too much; I wanted to create a circle using bezier curve drawing commands. Simi... |
I'm a student in college, and while I have coded a lot, I still feel like I've only scraped the surface. I have learned a lot of things over the years, but very few of my professors ever did code reviews and I feel like I may have some bad habits that I may be overlooking, one that was pointed out to me was that I didn... |
I wrote the following script in the hopes of streamlining the finding and reading of multiple manual pages. Since I am always looking up different utilities' manual pages I thought this would a good learning aid.
#!/bin/bash
while true
do
echo
echo "1) /bin"
echo "2) /sbin"
echo "3) /usr/bin/"
echo... |
Problem
A single line should be separated by Environment.NewLine so that each row has a length of columns (expect for the last one that may be shorter).
Below is my solution:
public static string Wrap(this string singleLineString, int columns)
{
if (singleLineString == null)
throw new Argum... |
I've made this function for to get a deep copy (recursive copy) of objects.
=> Sub-objects aren't references to the sub-objects of the original object. Instead they are objects on their own.
Here's my code ...
Attention: Most of it are test data and an additional test-function.
// ----- Test data -------------------... |
I've tried asking about the performance on the HackerRank discussion forum, it didn't work out.
The task is to write a program with three operations:
1 x Push the element x onto the stack.
2 Delete the element present at the top of the stack.
3 Print the maximum element in the stack.
The first input ... |
Would appreciate any suggestions or improvements, I'm sure there are many. Especially so on the way I've avoided multiple hits by the missiles; shifting the asteroid into a separate group to enable the animation to continue without registering more hits and hence addition to the score.
P.S As it stands my game has a sh... |
For many console applications it is handy to be able to receive input and output at the same time from multiple threads.
This is supposed to allow receiving input commands from multiple threads, while simultaneously outputting.
Console.h
#pragma once
#include <iostream>
#include <string>
#include <queue>
#include <mut... |
I want to find average of an array of objects based on their key values using the new functional programming style. I found my way around array reduce and solved my problem, but not sure if this is the best way to do it.
Please take a look at my code and see if this is the way to use reduce for my purpose.
Let's say ... |
I wrote a little Javascript rock/paper/scissors/lizard/spock game and when the user clicks the button to make their choice from the five options, I choose the computer's randomly and then compare the two to find a winner and output the result. It works, but I have the feeling that the findWinner function can be a lot ... |
I'm new to Scala and learn it by solving some Project Euler problems. Here is the solution to problem 42 from Project Euler.
The task is to read words from file, then sum ordinal numbers of each character (e.g. sky =19+11+25=55). One need to count all words for which this sum is a triangular number (satisfying \$\frac{... |
Just finished an assignment in Python where one part was to write a function to find the correct rotation in a encryption similar to a Caesar Cipher..
As mentioned it's already finished and works as intended. The course is an introduction to Python, but I do have experience with other languages since previously.
I was ... |
I have a set of data which represents a set of nodes, each node is associated with a value (represented by a color in the image). What I want to achieve is selectively changing those values.
The mesh represents a porous system (say a rock for example) model. The pressure in my system is specified at the nodes. I want t... |
I am curious as to what improvements to my code can be suggested.
package concepts;
import java.util.Iterator;
import java.util.NoSuchElementException;
public class LinkedList<M> implements Iterable<LinkedListNode<M>> {
public static class LinkedListIterator<O> implements Iterator<LinkedListNode<O>> {
pr... |
I am job-searching and putting together some code samples. Just wondering how it looks.
Here is an example of some code, from a custom WordPress theme, that works and is in production:
Homepage Template
<?php
/*
Template Name: Homepage
Requirements: Advanced Custom Fields plugin
*/
?>
<?php get_header(); ?>
<section... |
Is there a better way to do this?
const data = [{id: 1, name: 'item1'}, {id: 2, name: 'item2'}]
const a = []
data.forEach(x => { a[x.id] = x.name })
return a // ['1': 'item1', '2': 'item2']
|
I'm using Sequelise with node.js, and I have a feeling the paradigm I'm using to modify objects is not working well, as my code is getting messy rather quickly.
The function User.createOrMerge is designed to be called after a successful social auth (Google, Facebook etc.), with kwargs being the social auth token to che... |
Related, but in C++
I have written a program that generates scrambling algorithms for and times a solving session of a 3x3 Rubik's cube.
Requirements for scramble and timer
The same face cannot be turned twice in a row.
The same family of faces (U/D, R/L, or F/B) cannot be turned three times in a row.
An "average" con... |
Thus code uses a mergesort-like algorithm to perform an outer join (in the database sense) on two sequences. (It's derived from the ActiveState recipe mentioned in the docstring.)
The actual algorithm is completely obscured by the extra code required to handle the possibility that either of the main iterators might th... |
The code below has many Lists<> but I'm not sure how to modify it. The only thing here that is an algorithm is the Fisher Yates shuffle algorithm. I am trying to put in good use an algorithm or just code better said to do this. It seems a bunch of code just used in repetition.
My question is, is there a way to make thi... |
Problem (inspired by Project Euler 29):
Consider all integer combinations of ab for X ≤ a ≤ Y
and X ≤ b ≤ Y
Return a sequence of distinct terms in numerical order
Input is a list of 2 integers separated by a space (" "), representing the lower and upper bounds (X Y). Input is read from txt file.
Output is a numeri... |
Here is a swift port of UIView subclass that I use often in my apps. It allows me to easily set gradients in place of the backgroundColor property, and also makes it very easy to create views that have one, two, or three rounded corners.
I'm not super familiar with the mechanics behind core graphics and drawRect, so ma... |
This code basically generates a random number of bubbles that animate from bottom of the screen to the top and repeats. When the mouse is in a certain distance (proximity) of the bubbles it scales those bubble and changes their background color. This Demo can explain better, how it works.
Now the problem is that whene... |
Question 5 for Project Euler is finding the smallest multiple of 1 - 20. My solution is not even close to most of the solutions I've researched. Any feedback, good or bad, is greatly appreciated as I've been self teaching how to code on and off the past year and a half.
function smallestMultiple()
{
var smallest = 0;... |
I have a need for a container that behaves like an unordered_map, but has a fixed capacity, and an eviction policy where the least recently inserted key-value pair is chosen to be evicted when an insertion is performed at capacity.
I've implemented this by creating a container which combines a regular unordered_map wit... |
The code below is my solution in python 3 to exercise 1.5 in Cracking the Coding Interview. I would appreciate feedback on both the algorithm (improvements to space and time complexity) and/or coding style. I think the time and space complexity of the code below is \$O(n^{2})\$ and \$O(n)\$ respectively.
The exercis... |
I have written some sorting algorithms in Rust and wanted to see how terrible they were.
What I am looking for:
Bugs
Performance improvements
Idiomatic code
Maybe even a functional approach to the sorting algos
Why is the merge sort so slow? Is it my implementation?
Note you will need rand = '*' in your Cargo.toml fo... |
I have slightly altered Marc Gravells 2-tier cache code which can be seen here. I changed it to use Stackexchange.Redis instead of Booksleeve and also added some retry logic and serialization.
public class AzureRedisCache : ICacheService
{
private static Lazy<string> _configurationOptions = new Lazy<string>(() => ... |
I am trying to implement Google Maps in Android. I am also trying to learn different design patterns.
I want to use location in more than one Activity hence I have used a class named 'GoogleLocation' so that I can reuse the code in other activities too. I am using MyApplication class to get the context.
GooglePlacesAct... |
I am beginner in Java. I coded Directed weighted Graph data structure by myself without anyone's help i want to have some constructive feedback regarding my program design, weather my code is perfect or it needs some improvements, Here is my code :
import java.util.ArrayList;
import java.util.HashMap;
import java.util... |
For my first JavaScript/jQuery project, I made a simple Blackjack game. However, I would like to have a more object oriented approach. I would truly appreciate it if someone can review my code and point out how I can make it more object oriented.
function reset(){
// Reset
$(".dealer-cards").html("<div class='... |
In my web application I want to load all data to client side from the server on power up.
After that I want all communication be managed through Signalr - meaning that each update the server will send notification to all clients and they will ask for the updated data.
However, I don't know what to do when the SingalR c... |
I needed to write zlib wrapper class for my application, so I can change it with different algorithm later if I want to do so.
Here is the simple version:
struct ZLibEasyCompressor{
bool operator()(const char *data_in, size_t const size_in, char *data_out, size_t &size_out);
};
struct ZLibEasyDeCompressor{
boo... |
I'm writing a Twitter™ bot for the Retrocomputing Stack Exchange site using JavaScript. To ensure that it doesn't tweet about the same question twice in a row, I request the account's timeline. My code should work, but I have a feeling that there's something "wrong" with the way I've written it.
The get_request functio... |
This is a question from HackerRank. I have solved it and want to know if it's the best answer I could have given in Python 3.
Sample code:
>>> from collections import Counter
>>>
>>> myList = [1,1,2,3,4,5,3,2,3,4,2,1,2,3]
>>> print Counter(myList)
Counter({2: 4, 3: 4, 1: 3, 4: 2, 5: 1})
>>>
>>> print Counter(myList).i... |
I put together a ProducerConsumer class that wraps the C#'s BlockingCollection class with some bells and whistles (producers can have multiple consumers, consumers can have lambdas, built in parallel execution, exceptions thrown on cycles, etc). As you can imagine it uses generics.
var producer = new GhostLine<int>();
... |
I've never been too bothered by the lack of present (and thus print) support for Factor collections and other objects, but I've never needed to generate Factor programs from JSON until now.
To that end, I use these methods to turn arrays, hashtables and assocs into roundtrippable strings:
M: f present
drop "f" ;
M: ... |
I created a basic desktop calculator using Python. Does anyone have any suggestions as far as coding best practices, readability issues, or just generic coding mistakes I might have missed? Any professional input you could provide would be greatly appreciated.
import tkinter as Tk
class Calculator:
''' main class... |
Initially I got this code:
import sys
import os
import random
from PyQt5 import QtWidgets
from PyQt5 import QtGui
from PyQt5 import QtCore
random.seed(1)
class Model(QtCore.QObject):
item_added = QtCore.pyqtSignal(int)
item_removed = QtCore.pyqtSignal(int)
def __init__(self):
super().__init__(... |
I have implemented the \$O(logN) + O(N)\$ version for the problem: How to find 1st and 2nd largest element in a non-negative unique array? The algorithm principle is from this stackoverflow answer.The comparison information in finding 1st helps find 2nd faster (\$log N\$ time).
But I am really depressed that my code is... |
Type a number \$n\$. Then calculate \$f(n)\$, where
$$ f(n) =
\begin{cases}
n-10 & \text{if}~ n > 100\\[1.5ex]
f(f(n + 11)) & \text{otherwise}
\end{cases}
$$
The output must show all the computations, such as
$$f(99) = f(f(110)) = f(100) = f(f(111)) = f(101) = 91$$
Is there a shorter and better way I can solve this?
#... |
To be honest, I am pretty new to coding. I want to analyse the articles my local newspaper publishes on ther website. To do that, I have a list of URLs and from that, I want to download and save all the articles published. This is my code:
from bs4 import BeautifulSoup
import urllib.request
import pickle
import time
d... |
is there anyway to improve? Thank you!
def fahren_to_celsius(fahrenheit):
return round((fahrenheit - 32) / 1.8, 2)
def celsius_to_fahrenheit(celsius):
return round((celsius * 9/5) + 32)
def celsius_to_kelvin(celsius):
return round(celsius + 273.15)
def kelvin_to_celsius(kelvin):
return round(kelvin - 27... |
I have the following data frame:
set.seed(1)
SOURCE <- as.data.frame(matrix(c((1:10),
sample(c("20-24","25-28"), 10, replace = TRUE),
sample(c("10000", "20000"), 10, replace = TRUE),
sample(c(1, NA), 10, replace = TRUE),
... |
#include <iostream>
#include <string>
#define NL "\n"
int main(void) {
//Acquires players first name
std::string introOne = "Welcome to The World of Magick\nWhat is your name?\n";
std::cout << introOne;
std::string playerName;
std::cin >> playerName;
//Asks for players gender
while(tru... |
This is my solution to exercise 1.6 in Cracking the Coding Interview. I am interested in receiving feedback on the coding style and time/space complexity.
The exercise statement is:
Implement a method to perform basic string compression using the counts of repeated characters. For example, the string aabcccccaaa wou... |
I created this Blackjack program as a first attempt at Ruby. Would appreciate a code review to see if I am doing things the Ruby way (is there a better way to get user input?), using OOP correctly and anything else you want to point out.
class Card
def initialize(suit, face_value)
@suit = suit
@f... |
I need to compare two XML columns. I currently have about 1000 rows of data that this is running against and it takes about 20min. Is there anyway I can improve this query to run faster.
SELECT
MAX(T.CaseName) AS CaseName,
T.PartNumber,
T.NodeName,
T.OldValue,
T.NewValue
FROM (SELECT
C.CaseName,
old.N.va... |
I have made a form where the submit button will show if the text box is focused and the button will hide if the text box is blurred.
These codes work fine. But I wonder if the jQuery code could be more simplified. Or is there any toggle function available?
var search = $("#search");
var button = $("#submit-button");
... |
I am building an implementation of System.Windows.Input.ICommand that is like the commonly used RelayCommand, but doesn't keep a strong reference to targets of the delegates it uses. Such a structure is useful for when a control wants to expose some of its functionality as a command (which can be assigned to a ViewMode... |
I'm writing a piece of JavaScript to make one or two ajax calls. There will always be one ajax call fired but it might be two based on cookie setting. If user is logged in then we call another service to get the data. I would want this to fire async that's why I didn't put the second ajax call in the callback of the fi... |
I am currently refining my understanding of data structures and as such, decided to implement a popular application of the Stack. Below you will find my implementation of the Balancing Symbols algorithm written in JavaScript.
My basic questions are:
How clean would you rate my code?
Is time complexity O(n): Linear?
Ho... |
I wrote this as an exercise. I think that I have some repetitive code in the "winner" function but I don't know exactly how to reduce it. Any other general advice would be welcome too.
#include<iostream>
#include<iomanip>
char table[3][3];
int turn=1;
void print_table()
{
for (int i=0;i<3;i++)
{
for (... |
I created this based on this website which calculates IP address information such as hosts, netmasks etc.
I'm quite new to C and I'm still grasping the idea of the whole array and pointers and bit manipulations. Code works the way I want it to work but I'd like to improve this. I would like to know how I did as well as... |
Just a little exercise to make me more affluent with strings and error handling, any improvements welcome!
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdbool.h>
#include <math.h>
#define MAXSIZE 1024
void retreiveStringInput(char *str, size_t buffersize)
{
for (;;) {
if (fgets(st... |
I'll start off by saying I'm way off in how this should be done. After spending much time on getting this to be clean it wasn't going to happen so I just did it anyway I could.
I'm trying to make some FlxStates that will show off some nice menus that I want to create. What I'm doing in this code is moving UI buttons f... |
Challenge
Find all possible moves for a knight on an empty chessboard.
Specifications
The first argument is a path to a file.
The file contains multiple lines.
Each line is a test case representing the position of the knight in CN form.
C is a letter from “a” to “h” and denotes a column.
N is a number from 1 to 8 an... |
This is my solution to Exercise 1.7 from Cracking the Coding Interview. I would appreciate any feedback on coding style and algorithm efficiency.
I do know that there is an existing function in numpy for rotating a matrix, however I am trying to implement this as an exercise.
The problem statement follows:
Given an... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.