instruction
stringlengths
71
39k
Maybe this is fine the way it is, but it seems messy. Basically I have dynamically generated HTML that will display a list of songs in a given folder. Each song has an ID, and I want to add a button that allows you to add every song in the folder. Right now it's creating the add all button with the array of song IDs as...
I am going through the Odin Project Ruby section, and just finished implementing a Caesar cipher interpretation. Should I use classes, or more than one method to distribute the flow? Is there really a need for initialization in this? def caesar_cipher(string, shifter) ciphered = [] string.split("").each do |c...
I want my code to write to a .csv file a bunch of patterns for Tic Tac Toe games (30000). I want to have 9 columns numbered 1 through 9 and in each have the number of the space in the grid that was played during that turn. Next a column with the entire sequence, then the moves the first player made, the moves the secon...
I have gene expression data that I represent as a list of genes and a list of lists of values. I average the expression data for any genes with the same name. For example: genes = ['A', 'C', 'C', 'B', 'A'] vals = [[2.0, 2.0, 9.0, 9.0], # A: will be averaged with row=4 [3.0, 3.0, 3.0, 3.0], # C: will be averag...
While re-writing some old JavaScript code to better handle large arrays, I ended up writing my own binary search method. I found many examples of binary search methods written in JavaScript, but all the examples I found returned -1 whenever the target was not found in the array. What I really wanted was the bitwise com...
I have a bunch of models (using activejdbc) Person, Company, Health, .... etc (I have 8 models). I'm showing an example of just one model Person In the first approach I have a data manager that handles all my insertions to my various models, for example for Person I have public class Person extends Model { static ...
I went ahead and quickly typed this up and am unsure on how to improve. How could this be optimized? Note: there are some functions from a custom library here that do exactly what they sound like they do (e.g. make_window or fill_rectangle). struct block{ int a, b; block(){} block(int first, int second) ...
At first I have three cards like this: ___ ___ ___ | | | | | | | A | | A | | Q | |___| |___| |___| and then I shuffle them to this: ___ ___ ___ | | | | | | | 1 | | 2 | | 3 | |___| |___| |___| So now I want to write a function that generates a random number between 1 and 3 and as...
In my app, I have several convertors, like these two: public class ThemeToTableStripeConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, string language) { if ((int)value == 1) { return new SolidColorBrush(Color.FromArgb(255, 34, 34, 34)); } retur...
I am in the process of refactoring some complex code that uses callbacks to instead use promises. I am trying to figure out if my proposed approaches make sense. /* Current implementation. Hard to test because of the intermingling of various controller functionality, such as preparing responses. Gets a little d...
I am doing an interview exercise problem from here. The problem is to find "all numbers that occurred an odd-number of times in an array". Here is my high level psuedo code thinking: Construct a map that will map integers to their frequencies. Iterate through the array, use the map to record the frequency count. Itera...
This contains some complex logic and it's very difficult to provide all the things here. My intention is to simplify the loops, variable naming, and other stuff. I am thinking about splitting this big method to two or three subsidiary methods for better understanding/reading. Any ideas about that? public static void Ch...
I'm looking for security feedback on the following fully functional code. The code is trying to safely use the Unix 'file' command to give details about the file. A hard link is used to create a safe filename that can be used in a command line. The paramref is a hash read from config, and considered safe. file_base_dir...
I have JavaScript widget code for collecting leads: // Create an immediately invoked functional expression to wrap our code (function() { // Define our constructor this.Widget = function(options) { this.widgetWrap = null; this.widgetClose = null; this.widgetHeaderTitle = null; this.widgetInput ...
I would like your opinion on my Java implementation of the merge sort algorithm on an integer array, since I'm not really into algorithms I'd like to know from you if this is a correct implementation and if it can be improved somehow. For example, it requires a lot of space for the sub arrays, but this should be normal...
I have written a program to reverse the lines of a file. I made use of the String [] approach with the String.split(separator) using a custom separator. import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io...
I have "translated" this example built with jQuery in vanilla JavaScript, but I'd like to know if there are better ways to do it. The jQuery version uses offset() function and on() for every events, while I've used this function for offset: function offset(elt) { var rect = elt.getBoundingClientRect(), bodyElt = do...
On an authentication view, there are some inputs, like password, email, etc and a sign up button which is enabled only if theses inputs are not empty. So what I have is this function: func canSignUpButtonBeEnabled() -> Bool { let password = self.passwordTextField.text.stringByReplacingOccurrencesOfString(" ", wit...
I wrote a bash script to automatically backup a server and upload it to a server level FTP server. I'm somewhat new to the making of crontasks and other stuff heavily related to Linux administration. It took me a few days but I got it to work. I am now wondering if there are any ways to clean it up or simplify it. #! /...
I am a beginner in programming and this is the third program I've written. This is an interactive game of rock, paper, scissors, capable of being modified to any number of turns. I would love to see how a more experienced programmer could simplify this and make it smaller. Please let me know how I could change this ...
Here is what the site looks like with the icons/images: #firstpic { margin: 0px; padding: 0px; display: inline; } #propic { width: 15%; } #somed { float: right; padding-right: 5%; display: inline; } #somed ul { list-style: none; padding-top: 30px; } #sp { padding-bottom: 10px; } #navigation { border...
I am messing around with shifting between stored procedures and business layer EF getting data rapidly then processing in memory. This works and on a static data range of 3 months I get execution time of 2.3 seconds Is there anything I can do to help the compiler increase CPU efficiency or even a better way to get data...
I am working on an application where the user will have flexibility to create and destroy a server instance at any port he/she wishes. User can create multi servers operating simultaneously - each dedicated for a particular client and independent of other servers. I have been working on this for quite sometime now, and...
Is there a better way to write this procedure? public List<IDenomination> GetInventory(int[] denominations) { var inventory = new List<IDenomination>(); foreach (var denomination in denominations) { foreach (var item in Account) { if (item.Currenc...
I would like to convert the following procedure to use Linq, but I'm not sure how to accomplish it, ForEach or Sum? public int GetBalance() { int balance = 0; foreach (IDenomination denomination in Account) { balance += denomination.Currency * denomination.BillCount; ...
I've made a nice little function to return a NodeList array containing all the inputs that have a specified name attribute: function GiveElementsByName(name) { var finalOutput = [], times = document.getElementsByTagName('input').length, inOutput = 0, inAll = 0; //For use later. while(times--) { if (document.getElemen...
I have finished writing a program, and was wondering if I could make it any more efficient or generally more sophisticated that the current version. The below section of code is where I think improvement could be made...any suggestions? EDIT: The below functions focus on the die roll result of '6' which allows the play...
I'm currently developing an Open Source project called sims3py using Python2.7. One overarching goal of the project is to ensure a Pure Python implementation of functions currently available only through a .Net-based library. Because the project must be Pure Python, 'cheats' using C code is not allowed (except for the ...
Before I get to the question, let me note that I'm a trained scientist, not a programmer; I've done my best to self-teach what I've needed to know so far, but in the interest of making my code usable for other people in my research group, I'd like to improve my code. I spent a weekend writing actual documentation for s...
In order to prevent SQL injection, I'm converting every character of a string to be inserted in the database into its ASCII value before performing the query. In order to read the value of the string from the database, I'm reversing the operation. Is this method safe? <?php function toDatabase($string){ $split = st...
I am making a small Blackjack game in Python 3. The part of the code I am unsure about is that which allows me to print nice ASCII versions of the card. ascii_version_of_card() and ascii_version_of_hidden_card(). What the program does: I am not seeking advice on the implementation of the Card() class. Only on ascii_v...
How can I shorten this? .equ SWI_PrStr, 0x69 .equ SWI_PrInt, 0x6b .equ StDout, 1 .equ SWI_EXIT, 0x11 .global _start start: MOV R5, #1 MOV R6, #1 MOV R7, #1000 LOOPHERE: CMP R5, R7 BLE LOOPBODY B LOOPDONE LOOPBODY: CMP R6, #5 BLT LOOPIF MOV R6, #0 B LOOPNEXT LOOPIF: MOV R0, #StDout MOV R1, R5 swi SWI_PrInt ldr ...
I'm developing on a web application where I have a start and a finish date and time and have to set the duration between it. There are inputs for dates and times. Then, I have this function which calculates the duration between the two of them, and they are working properly. The duration, though, needs to be dynamic. S...
I am working on a base framework for my various PHP related projects. I have grown since beginning all of this, but the one area I am still having difficulty/concerns with involves the dependencies of my various classes. The real dependencies involve only the 'Core' Helper classes for the site including the following c...
I have the following JSON: { "items": [ { "item": "abc", "status": "ready" }, { "item": "def", "status": "ready" }, { "item": "ghi", "status": "done", "items": [ { "item": "ABC", "status": "ready" }, { ...
I was wondering what is the best way to implement a fan out type of functionality with Java 8 Completable future. I recently rewrote a function that had a bunch of old Future instances and then calling get in a loop, blocking on each one, to a somewhat cleaner variant using CompletableFuture. However I am seeing about ...
I am having a tough time submitting this code to UVa Online judge and having it pass. I keep getting the message - Your program used more CPU time than what is allowed for this problem. That means that your algorithm is not fast enough or that it entered into an infinite loop. The challenge: for each line of input, whi...
I've been writing this prime number calculator, and I've gotten it pretty quick in comparison to most I've seen knocking about. This one uses the Sieve of Eratosthenes approach, and I've optimised the code as much as possible with my knowledge. A more experienced mind might be able to make it better. Machine: 2.4GHz Qu...
We have this long .htaccess mainly rewriting our URLs. Everything works fine (except blog titles containing a ' , but we're working on that) but I'm sure it can be shorter. Feel free to review our code and propose some generic or simpler ways to rewrite the URLs instead of rewriting each and every concerned page like t...
I'm trying to decide if I should put time into refactoring this tiny class. PathParser only uses string locally and every other method is used by an outside class. Should I put the small bits of logic into initialize or keep this as is? class PathParser attr_reader :str def initialize(str) @str = str end ...
I have a piece of code that tries to get some data from a different services, falling back to the next one if previous fails. The code look a little bit ugly, though. Any suggestions on how to rewrite it in a more concise way? (defn get-data [query] (let [data-cached (get-data-from-cache query) data-service-1...
Summary: I created this DebugTimer class so that I could test performance of code in a much cleaner/shorter syntax. Prior I was using regular timers and wrapping them all in #if DEBUG #endif. I'm relatively new to events, have I done them well? This is the first time planning a snippet of code to be used externally ...
def getRandomNumbers(count, min, max) array = [] while array.length < count tmp = rand(max) + min if array.include?(tmp) next else array.push(tmp) end end return array end def prettyPrint(someArray) string = "" someArray.each do |item| string += item.to_s ...
StringTokenGenerator is an interface (or abstract class) I've created to the specific task of generating a string token of a given character set. It allows appending characters to it and then it can be used to receive a string token. I wrote this for the second version of ExpressGenGen a code generator generator. Secon...
I have written a program to print a binary tree level by level on different lines, like the tree would actually look if drawn on paper. I have done a BFS traversal and then I proceed to print the tree assuming it is complete binary tree: import java.util.ArrayList; import java.util.LinkedList; import java.util.List; im...
I was working through a codechef easy problem here. I've got to a solution, but it only passes the Subtask #1. For the other two subtasks, it shows TLE (Time Limit Exceeded - which is 1 second). package com.codechef.solutions; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader;...
I would like to use code below for general purpose dynamic array implementation in my future code. How does it look? array.h: #include <stdlib.h> /* This file describes structures and functions for general purpose dynamic array. */ struct array { void *data; /* Points to where the data is */ int numE...
I come from VB6 where everything is single threaded, so I've never written a lick of multi-threaded code before. I just added a wait cursor to one of our GUI's by stumbling through the docs, but I'm unsure I've done it the best way. Did I? Control is a Winform view and the code below is located in the presenter class. ...
This originally appeared in Facebook's hacker cup 2013. Solving it was fun, though I find myself looping through similar data quite often. Challenge: Print the maximum beauty of strings. Specifications: The beauty of a string is the sum of the beauty of the letters within. The beauty of each letter is an integer b...
I'm building a prototype MVC web application as a learning exercise so I'm avoiding existing frameworks. I'm interested in feedback on the following approach The view consists of JSPs which use EL to present data stored in the appropriate scope (mostly session scope). There is a single servlet called Controller. The jo...
I need to write a function in Python that makes sure the user entered a valid JavaScript origin. If I understand it correctly, the origin includes the scheme, hostname and port (port and scheme might be implicit, defaulting to 80 and http respectively), so would this be a correct way to validate it? import urlparse de...
This script takes input from poker tournament pages at pokeratlas dot com, and outputs a CSV file that I can import to Google Calendar, listing each of the tournament events, start time, location, and a link back to pokeratlas for their full detail page. I've used moment, Q, and cheerio. I learned moment specifically ...
I have the following SCSS and I'm curious as to how I can improve it, and reduce the amount of repetition... I plan on adding more colors, but I don't wish to keep copy/pasting the same block over and over. .panel-alt { &.panel-default { border-color: $btn-default-bg; > .panel-body { ba...
I'm trying to make a star based rating system. First of all, I don't like to make it all with JS and only innerHTML the rated stars in a given div. I want to make it more like a plugin with the ability to make anything votable and you just have to pass the classes. My biggest problem, however, is that I'm setting clas...
As practice I wanted to write a Socket in Java: /* User: koray@tugay.biz Date: 21/02/15 Time: 13:30 */ import java.io.IOException; import java.net.ServerSocket; public class MyServer { public static void main(String[] args) throws IOException { ServerSocket serverSocket = new ServerSocket(8888); ...
I am working on a game where the player can walk around a world comprised out of a grid of tiles. The World object contains a HashMap of Region objects which each has a HashMap of Tile objects. For the libGDX side of things, the Game object creates the different Screens of the game, and switching between Screens is ...
Follow-up of 2048 (game) solver I improved the script, using standard search methods like expectimax. Now it goes easily to 2048, but not really further, the difference with the highly efficient answer is that they represent the whole board in an integer, then they can go to further depth in the search (10 million of m...
I've got an app that's got an activity/timeline like view. Since I don't want to retrieve the entire timeline every time, I'm caching all the events. Currently, this is how I go about it: - (void)saveEventArray:(NSMutableArray *)eventArray { // save hier in bg dispatch_async(kAsyncQueue, ^{ __block int ...
While preparing a solution for the CodeChef - magic tricks, an easy question about counting the frequency of given character from the string slice, I came up with the following solution: input_str = input("") t = int(input("")) for i in range(t): c, l1, l2 = input("").split() l, r = int(l1),int(l2) print(in...
I've got a simple spec for defining character sets, ranges, or wildcards. I'd like to take the string and appropriately create an array based on these rules. I have a solution but I'm sure there is a better way! Single characters may be used Sets and ranges are enclosed in brackets [] Sets are comma separated, [1,3,S]...
I'm working through a scraping function where pages of results lead to product pages. I've added a default maximum number of results pages, and pages per set of results, to prevent a simple mistake of crawling the whole site. Here's what I have so far. Does the way I'm implementing the maximums with the for loops mak...
I am new to assembly and have made a simple addition program to sum two integers read from the keyboard. The program outputs correctly, but I want to know if there is a way to streamline my code. It seems a bit cumbersome for such a simple program and I may have instructions that are unnecessary. # Author: Evan Bechto...
I tried to make a Server using Java with a Thread Pool. Any review is welcome: /* User: koray@tugay.biz Date: 21/02/15 Time: 21:12 */ import java.io.IOException; import java.net.ServerSocket; import java.net.Socket; import java.util.Stack; public class MyConnectionAccepter { private Stack<MySocketThread> mySocke...
I've created a form to choose the settings: These settings are automatically saved in a file from the game client in this form: ["Setting"] = { ["track"] = "Spell Reflect", ["duration"] = { ["minimum"] = { ["enabled"] = 1, ["value"] = 3, }, ["maximum"] = { ...
I have the following Main class: public class Main { public static void main(String[] args) { try { MessageWriter writer = null; if (args.length < 1) { throw new IllegalArgumentException("There is no input file path"); } else if (args.length == 1) { ...
Due to some clueless soul, we have several fields in a legacy database that uses a 6-digit integer to represent a date in (YYYYmm) format. The date field is assumed to be the last day of the given month. I have written the following method to perform the conversion from int to java.util.Date: public Date convertIntToDa...
I am working on a small project which utilizes a 3rd party API. Many of the queries from the API can take 5-10 seconds so to keep the front end moving a bit faster I decided to cache the responses from these calls. I ended up building my own cache implementation. There are 3 classes in this implementation which are pos...
I want to see if anyone knows how to optimize the code below: public class smallestTest { public static void main(String[] args) { double resultSmallest = smallest(2.5, 3.5, 4.5); System.out.println("The smallest number out of 2.5, 3.5, and 4.5 is: " + resultSmallest); } /** Computes the small...
For those who aren't familiar with the bisection method for finding the root of a function (i.e. finding where \$f(x) = 0\$) the basic idea is: Take a function \$f(x)\$ and an interval \$[a,b]\$ If \$[f(a)] \cdot [f(b)] < 0\$, there is a root in the interval, as one of those is a negative value Repeatedly half the int...
I have a large matrix samples, I want to make another matrix sampleProb which is the same size, but modified as below: %samples is a 1000*1000 matrix, M = 1000 sampleProb = zeros(1000); for i = 1:size(samples, 2) for j = 1:M for k = 1:M if (k ~= j) sampleProb(j, i) = sampleProb(j, i) + normcdf(samp...
Overview:: I have a Restful API that pushes all /api/{version}/{Repository} into my ResourceV{1}Controller depending on the {version} number. That Controller extends my Abstract Controller that has the majority of the controller logic, the ResourceV1Controller would load the V1 Interface for the API, and ResourceV2Cont...
I'm trying to implement the Pollard p - 1 algorithm seen here, in Java. It has a C implementation here. I am using it for numbers without any smaller factors so trial factorisation isn't needed. My implementation can factor numbers such as 15236506168104630133 but it takes around ten minutes. I also would like it to f...
This is a program I wrote to convert binary to ASCII. I am still learning ARM assembly. How can I improve my program? Are there any bad programming habits in my code? I've tested it on Raspberry Pi and Android. @ @ ARM assembly programm which converts binary to ASCII @ written by Kyle Kersey, (C) 2015 @ .global main ...
I'm currently just working on a Chess game project to improve my object-oriented skills. It is currently only at the starting stages and there is quite a bit missing (such as error checking) but I thought before I go any further I should get some advice on if I am using correct practices and if there's anything I could...
I was trying to solve the Diwali Lights challenge on HackerRank. Problem Statement On the eve of Diwali, Hari is decorating his house with a serial light bulb set. The serial light bulb set has N bulbs placed sequentially on a string which is programmed to change patterns every second. If atleast one bulb in the...
I wrote a function for interacting with my PIC16F1788. The code sends pulses out the RC4 port at a specific frequency, to make an LED blink according to that frequency. So the LED will blink faster or slower depending on the magnitude of the frequency. I decided to take a blinking code and vary the delay time according...
I am interested in splitting any list into consecutive subsets based on a k-value. For example, [1,2,3,4,5] splits into [[1,2],[2,3],[3,4],[4,5]] when k=2. If k is bigger than the entire list, then an empty list will be returned. I am unhappy with my current solution and would like to have suggestions on how to impro...
I understand that using eval is extremely dangerous as it can execute deadly commands as an input by the user. I'm trying to write a code to get a letter grade from a number between 0 to 1. I was trying to write it in the most elegant way. Is this safe? try: score = float(raw_input('Enter score: ')) except Except...
My goals are: Have 2 main domains .com and .dev for production and local installations Have 2 main subdomains. One for the site and one of the application Site must be public and application always to be secured. My take on the above: <?php $approutes =function (){ Route::group(['middleware' => 'auth'], function...
template <class T, int max_size> class FixedSizedUniqueStack { std::vector<T> m_vec; std::unordered_set<T> m_uset; public: FixedSizedUniqueStack():m_vec(max_size){} bool push(T& x) { bool success = true; if(m_uset.insert(x)) m_vec.push_back(x); else success = false; r...
I've been working on a Java-based mathematics library focusing on vectors and matrices. I plan to use it for an important upcoming project, so the classes are analogous to data types available in GLSL (e.g. Vector2 for GLSL's vec2, Matrix4 for GLSL's mat4, and so on). I'm trying to only expose interface to clients (e.g...
This code reaches time limit on 1 test case, solving this challenge. The approach that I'm using is from the book Algorithms Functional Programming Approach, which is a backtracking depth searching method. How do I improve speed of this code? Or is there better way to do it? searchDfs :: (Eq node) => (node...
I am a newbie in F# and I am thinking about use F# in my next project. The project will work the database and I need to store and retrieve instances of objects in the Db. Could you please check my code and say if there is something that I can improve? Here is a simple object: namespace Entities type Item(id : string,...
Since I am fairly new to Python I was wondering whether anyone can help me by making the code more efficient. I know the output stinks; I will be using Pandas to make this a little nicer. from xlrd import * def main(): '''This Proram reads input (A:clone name, B:sequence, C:elisa) from an Excel file and makes a...
This is a two-part job: to identify a word to find the top k words I've tried to use regex to split but it's taking 10x more time when string is really long. The top k strings are found using a priority queue. I've created a min priority queue for first k element, if the frequency of the next word is greater than the...
Is there a way to write it in more efficient and modern (Up to date design pattern) way? static Dictionary<string, Dictionary<string, string>> m_LUApplicationParams; public string LUApplicationParams(int applicationId, string GuidId, string variable) { if (m_LUApplicationParams == null...
Can you review below code for performance and stability considerations? It is supposed to take a filename or NULL. If it is a filename, read given file into memory. If it is NULL, read from stdin into memory. struct file_data { char *data; size_t numChars; }; /* Read whole file into memory */ struct file_data ...
I am currently adding a voting system to my website. Below is my voting class. I feel that it could be simplified and that there is repeated code regarding the functions, although to the best of my knowledge this is the simplest I can make it. I would love to hear other implementation ideas and systems that have been u...
I made a panel of buttons which run commands when pushed. In order to not have the command run on every loop if the button is held down, I am comparing the button to a previous state and only run if it is not, like so: buttonStateR1 = digitalRead(redButton1); if (buttonStateR1 != lastButtonStateR1) { if (buttonSta...
I'm basically a newbie in android app developing. So I'm not sure if this is the right way to write these codes. I have made an app called "Zconverter". It has 9 fragments and the code i m showing here is the smallest of them all. All the fragments have the same type of code. This app works just fine but i m not sure i...
I've read a little about binary heaps/priority queues and decided to try my hand at making my own implementation of one. I'm not the most experienced programmer and I would be really grateful if you guys could take a look at my heap class and tell me if it's a good implementation. What can I improve here? Any feedback ...
I am playing with async and I figured I'd write a parallel implementation of Quicksort while trying to look at various optimizations. I want to keep the generics (and the overhead of the virtual calls going on here). Other than that I am looking for optimizations that can be made. class Program { static int[] initi...
The goal is to draw random tarot cards from the suit, number of cards is determined by the amount of HTML elements with 'card-container' class on given page. The deck is structured as follows: major arcana (trumps), numbered from 0 to 21 minor arcana have 4 suits, each numbered 1 to 14. The result cannot contain dup...
On CodeEval, there's a Grid Walk challenge: There is a monkey which can walk around on a planar grid. The monkey can move one space at a time left, right, up or down. That is, from (x, y) the monkey can go to (x+1, y), (x-1, y), (x, y+1), and (x, y-1). Points where the sum of the digits of the absolute value of the x ...
I have two tables for storing comments comments CREATE TABLE `comments` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `text` text NOT NULL, `author` int(10) unsigned NOT NULL, `time` datetime DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 comments_ratings CREATE TABLE `c...
I decided to make a solution in Haskell to a problem that I found on another post here at CodeReview (link: The Beauty and the Strings) I would like suggestions on how to improve letterFreqs. I have tried searching for mutable arrays that could help with performance. But is it worth it? The array that is modified of...
My implementation of a binary-to-bits converting function: #include <stdio.h> #include <limits.h> unsigned char *return_byte (unsigned char source) { static unsigned char byte[CHAR_BIT]; unsigned char *p = byte, i; for(i = 0; i < CHAR_BIT; i++) p[i] = '0' + ((source & (1 << i)) > 0); return p...
I am refreshing my university knowledge on C++ due to a job interview and I am trying to understand everything in depth. Is there any reason for me to use pointers and dynamic memory features of C++ in this example? It's not that clear to me when should I use these features. #include <iostream> using namespace std; i...
During my research in Rigid Body Dynamics, (where Contact Graphs are used to solve the contact problem) I came across the question if it is possible to define at compile time a directed graph (class) where each Node has a NodaDataType and each Edge has an EdgeDataType. The graph should have the following properties: ...
I am currently creating a chess game, and have so far done the board. The board is pretty much a two-dimensional array, where Pieces are stored in their positions. For example, board[0][0] will be the position A1, which at the beginning of the game, is a White Rook. The board has some useful methods (as well as require...