instruction
stringlengths
71
71.9k
I have a hash map which maps to some strings which serve as prefixes and are of small length (max length is 6): Map<String, String> map = new HashMap<>(); map.put("codeA", "100"); map.put("codeB", "7"); map.put("codeC", "0012"); etc This is fine so far, but I also need when provided an input string to actual...
EnumSpace This file enables the use of a utility I like to call "EnumSpace". This utility is enums and namespaces combined together in order to create an entity that acts like an enum that is able to inherit and extend an already existing one. It provides three macros for that purpose: ENUMSPACE_CREATE ENUMSPACE_EXTEN...
I have this function which will fire off a specific template depending on which element is selected. However, with the way it is, I'd have to update the JavaScript and the HTML when a new element is added. What I'd like is to have the function scale up to as many HTML elements one would add. So far I have figured out i...
I've come up with a prime number finder I call the "Progressive Sieve". I wouldn't doubt it if this has already been thought of. Anyway, here is the idea, an implementation in C#, and benchmarks: Premise: A number is prime if it cannot be divided evenly by any prime number below its square root. Implementation: stati...
I'm trying to make a program which prints different sized grids (n by n grids). These grids cannot have the same number in any column or row (like a Sudoku). My bruteSolve() method runs through every combination and then isValid() checks if the rows and columns add up & multiply up to a certain number too - if they d...
Introduction The function divides a range given by a begin_iterator and an end_iterator into n sub-ranges of the same format, where the sub-ranges must be as equally sized as possible. Example Consider a set of size 10: \$\{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 \}\$ The output would be is a set of n = 3 sub-ranges: \$\{ \{ ...
I worked through the Flowers challenge on hackerrank.com and would like to get feedback on solution and algorithm implementation. It was suggested by hackerrank to review greedy algorithm to solve this challenge. As far as I understand this is an implementation of greedy algorithm. You and your \$K−1\$ friends want ...
What my code does is that it takes input as to which function to use, and then plugs in the appropriate data in to the given function. For example: User input: force(1, density = 10.0, volume = 5.0) Result: 490.5 The 1 is the equation ID, and the rest are user parameters import Constants as C import Errors as E def ...
I'm a C# developer looking to learn more about Python and how to think in a more functional programming manner. I have the following which takes a series of grades and returns the average: grades = [100, 100, 90, 40, 80, 100, 85, 70, 90, 65, 90, 85, 50.5] def grades_sum(scores): total = 0 for score in scores: ...
I wrote some code using ChucK : Strongly-timed, Concurrent, and On-the-fly Music Programming Language and would like a review. I broke down the logic into a number of classes, all of which are shown below. This is pretty new to me, and I would appreciate any and all constructive criticism. What the main script fizzbu...
in-nest-sequence is a sequence generator that takes a function and an initial value, and the return value of invoking the function on the current value is used as the subsequent value. For example, (in-nest-sequence add1 0) returns the sequence (0 1 2 3 4 ...). Recently, soegaard challenged me to write a define-sequenc...
From this question and some help I created a thread safe logging class on which the name of the log file is same as the current date (short date) when the log entry was added. e.g. If I create ten entries today say they will all get written to log file named "07.10.2015.txt". I want to use this class from DLL. I am cur...
I have a Spring/Hibernate application with the following domain class (irrelevant code stripped for brevity): @Entity @Data public class Program implements Serializable { @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long tid; @Column @Convert(converter = ProgramStatusConverter.class...
I'm learning data structures. I'm working on linked lists at the moment, and I'd like to have a strong grasp on them. Below is the last problem I solved. I'd like to know what you think of the solution and what can be done better. The problem consists of reversing a linked list from position m to position n. 1 ≤ m ≤ n...
Prompted by a meta answer, here is an HTML page I'm deliberating over in JSBIN and I would like your review, please. I am not looking to implement the logic, just please focus on HTML & CSS. Are tables a good candidate to mark up purchase items? I've seen this implemented as a list in each column, which I thought was ...
I created a very simple interpreter in Python. It's capable of doing basic math (unfortunately with only two numbers), creating quines and printing text. import re def prompt(): userInput = input("> ") return userInput def parse(command): if command.startswith("+"): numbers = re.findall(r'\d+', co...
Here are three classes in my project. They work as expected. What I'm not sure of is the passing of the target into style sheet. What is going on is that I want the matrix as a whole to be left-aligned on the screen, but each entry to be centered within its column. The GetHorizontalAlignmentQ method accomplishes that. ...
I am trying to get the hang of Roslyn at the moment, and to implement a couple of code fixes for specific fields/properties that should usually be readonly (in the case of a property, to have no setter). I've started from the "Analyzer with Code Fix (NUGET + VSIX)" template and now have two diagnostics implemented in t...
I have to sort some numbers with Perl. But some of the numbers are undefined. Perl's compare operator <=> treats undef as -inf 0. The result is, that the undefined numbers are at the beginning: perl -MData::Dumper -e 'print Dumper(sort {$a <=> $b} 3, undef, 2, 1);' $VAR1 = undef; $VAR2 = 1; $VAR3 = 2; $VAR4 = 3; I wan...
I've just created my first set of related classes in React and would like to get feedback from more experienced React developers. I've used ES and completely vanilla React. The application is a shopping cart where the cart item quantities update the totals. The one file situation is because it didn't seem to like multi...
I have the following concerns: Is Set a good choice for getting products? What are drawbacks of Set for this purpose? Is it better to do something like common.retainAll() or to get products through a request with WHERE to the database. For now I do three requests in: getProductsByCategory, getProductsByManufacturer, g...
This function iterates through a open dialog box that has 4 values in it all optional except for aircraft1, aircraft2, warning_or_alert. aircraft1, aircraft2 t_sep # time value in format 00:12:21 t_min_nm # time value in format 00:21:21 c_tracks # can be either 'on' or 'off' warning_or_alert # can be either 'wa...
I missed points for putting implementation in the driver class, rather than having the driver class only make call methods in other classes. I'm not sure how to move the implementation outside of the main class. Suggestions are welcome! /* *Deitel Chapter 6 Exercise 6.30 */ package guess; import java.util.Scanner; /...
I'm trying to learn more about object oriented programming and I have a few questions about the class below. I'm working in Visual Basic.NET My questions are Is there a better place / way to show the MessageBox.Show? I'm being forced to use a single Oracle Connection, in my sample cnn is declared with Friend scope so ...
I'm using VB.Net, MVC 5, EF 6, and Linq. I have a list of Integers (category attribute IDs). I need to create a second list of String (values). There will be one string for each integer. I am currently accomplishing my task like this: Function getValues(catAttIDs As List(Of Integer), itemID As Integer) As List(Of St...
Just curious if my authentication is secure enough, really. Also wondering if I should ditch the secret variable and just use password everywhere instead. Note: the method logic must remain seperated because the same User object will have CRUD methods added at a later date. The table structure: CREATE TABLE IF NOT EXIS...
I was asked this as an interview question. I was also asked to assume that there is a function which can compare and say two nodes are identical. I would like to implement that function as well. I'm not sure what's a sure shot way of saying that in pure JavaScript. O O / \ / \ O O O O ...
public static int lastDigit(int a) { a = a % 10; if (a <= 0){ a *= -1; } return a; } This is my solution. The course hasn't taught if else yet, so I'm wondering if there is a way to do it without the if else. public static int lastDigit(int a) { a = a % 10; return a; } The problem with this is tha...
I just watched Raymond Hettinger's talk on making Python more Pythonic and realized I should be putting a lot of his ideas into practice, particularly wrapping API's in a class that makes everything simpler and easy to use. Here's what I'm doing to wrap PyMongo: from pymongo import MongoClient class MongoDB(object): ...
This is code that's part of a library (closed source) that I have that generates a unique nonce value for Twitter OAuth. Essentially, it generates a random number, combines it in string form with an extra string separated by a pipe, computes a Sha-1 hash, and then repeats the process if the Sha-1 hash (when converted t...
This is part of my first OCaml program. Its job is to replace a set of placeholder characters with umlauts. Taking the German word Ruebe as an example, the program turns it into Rübe. Other examples are Moewe -> Möwe and aendern -> ändern Generally, everytime the program encounters the characters ae, oe, and ue it turn...
I've already expressed concerns about this type's constructor, and I've sort-of* implemented the changes suggested in the answers I got there. Recently I added even more parameters to that constructor - namely the ParentDeclaration and the Annotations. The Declaration type is absolutely where these things belong. For e...
Today I stumbled upon CodinGame, a site with programming challenges. I'll describe one of them. ASCII art allows you to represent forms by using characters. To be precise, in our case, these forms are words. For example, the word "MANHATTAN" could be displayed as follows in ASCII art: # # # ### # # # ### ### # #...
I want to know how I can make this old code faster, cleaner and compact. It may look like bad code because I did it when I first started with Python. # -*- coding: utf-8 -*- import urllib import time import os from twython import Twython from bs4 import BeautifulSoup as bs class Alfred(): def __init__(self): ...
From my C university book 'The C Programming Language' by Brain W.Kernighan and Dennis M.Ritchie. Excercise 1 - 20. Write a program detab that replaces tabs in the input with the proper number of blanks to space to the next tab stop. Assume a fixed set of tab stops, say every n columns. Should n be a va...
I am stepping into a new realm with this project, Reflection. I have written some working code (below) that will potentially store POCO objects in a redis cache (and eventually backed by Table or other nosql persistant storage). Currently it only reads the objects from the cache, but after this review I will be attempt...
I've written a simple little Groovy class handling my database interactions. All it has to do is check if a row exists in a target table with primary key values which match those of an incoming map. If a row exists, it updates the row based on the differing non-primary key values; otherwise, a new row is inserted. impo...
Does anyone have tips to improve the speed, clarity and accuracy of this non-recursive alpha-beta algorithm? It's my first program written in C. // Tic-Tac-Toe - Iterative implementation of alpha beta tree search. // Built with Microsoft Visual Studio Professional 2013. #include "stdafx.h" #include <windows.h> #inclu...
This is a multiple choice game. It has a web page where you enter a question, which can have multiple answers along with multiple options. Can anyone recommend any improvements for my code? //correct & options are both arrays. These arrays are being passed through an AJAX call function addQuestion($topicID, $difficulty...
This takes a list of categories and organizes them into a tree-type structure based on their parentId. This code works, but is obviously a little over-complicated. How can I optimize it? type ValidString = | ValidString of string | NotValid type CategoryStructure = { Id: ValidString; ParentId: ValidString; ...
I created a really modular way of creating a feature-rich table, including filter input text, sortable columns by ascending and descending order, and the ability to order table rows onMount. This is my first big react endeavor some I'm interested in any and all feedback I can get. Here's the live example. Here's the br...
Can the following code snippet be optimized or am I doing it right? <svg xmlns="http://www.w3.org/2000/svg" width="100" height="100"> <mask id="a"> <circle cx="50" cy="50" r="50" fill="#fff"/> <rect x="50" width="5" height="100%"/> </mask> <rect width="100" height="100" fill="gray" mask="url(#a)" /> </svg> http://jsfi...
I didn't use multi-threading so far as I didn't need to. But as far as I've read, implementing them will make my program slightly faster than it actually is. from validate_email import validate_email import os # the program is reading each line from "emails.txt" and after it checks each email it will remove duplicates...
(See also Noughts and Crosses GUI game in Java - Part 2/2: GUI) I was working on a GUI game of Noughts and Crosses, and this is what I finally got: Unfortunately, the entire source code for the program does not fit in a single, so I have to try to split them in logical parts: this post is about Model and a little bit...
(See also Noughts and Crosses GUI game in Java - Part 1/2: AI) This part is dedicated to the View/Controller of the MVC pattern. So once again these are the building blocks of the Noughts and Crosses game: ConfigurationFrame.java: package net.coderodde.game.crosses; import java.awt.Color; import java.awt.GridLayout;...
I built a simple proxy using Meteor and its Iron Router. It currently fails at passing through other than 200 or 500 status codes, which I guess suffices. Is this proxy.js the best way to bypass CORS without modifying remote or Apache/Nginx server settings? "use strict" // call with "/proxy?url=" + encodeURIComponent(...
I have read a lot about serialization and I cannot figure out how I am able to serialize then deserialize multiple objects. I am very much a newb to Java, so please bear with me. My code currently works, but my logic is flawed. I have an object called "club", which contains several fields to be serialized e.g teamname....
So I've been writing a unit test using Rhino Mocks to a controller in my ASP MVC application. The test passes, but I'm interested in your opinion and if there's something I should be doing differently or what it could be. Here's my test method: [TestMethod] public void TestSlideView() { // Arrange ...
In this problem, you need to calculate someone's pay by multiplying their salary (double)by the hours (int) worked. If they worked for more than 8 hours, you pay them 1.5 times their salary for however many hours more they worked. Here is my solution. public static double pay(double a, int b) { if (b > 8) { return ...
The problem When you work with Python interactively (e.g. in an IPython shell or notebook) and run a computationally intensive operation like fitting a machine-learning model that is implemented in a native code, you cannot interrupt the operation since the native code does not return execution control to the Python in...
I'm writing a animate method to perform DOM animations. I know there are a lot of libraries out there that already does that (and I use some ideas of them) but I usually prefer writing my own code to pinpoint my problem. The code below is working perfectly, but something with the structure is making me uncomfortable. I...
I'm working on a project where I often want to turn class instances into dictionaries to write them to MongoDB. I'd like some feedback on the following: def getDict(self): self.dict = dict() for key in self.__dict__.keys(): if key not in self.NOT_INCLUDE: # class variable try: ...
This is my code for The Mysts of Aesthoth so far. I'd like to know if I'm following best practices, and what can be improved. /* ______________________________________ This Program was made by: Andrew Tew ______________________________________ */ #include <iostream> #include <string> using namespace std; int main() ...
I'm looking for tips on cleaning this up. I think it's legible, but it sure ain't pretty. In particular, I'd love to clean up the hitCheck function. I've dealt with switches before in other languages, so I was kind of stuck on trying simulating that. getReady looks messy to me, but I'm not sure how I'd go about tidying...
I saw this question, but was unable to answer because of my inexistant knowledge of Rust, so I decided to try and write an algorithm on my own and put it for review. There is the casual way to compute factorials: \$n! = \prod\limits_{k=1}^n k\$ public static BigInteger fact(BigInteger n) => n == 0 ? 1 : n*fact(n - 1);...
I'm creating an RPG type game, and now I am working on procedural town generation. The algorithm for that creates some roads going horizontally and vertically, and then attempts to place buildings in the open spaces. Once a building is successfully placed, I use this algorithm to iterate through the positions of the w...
This is the seconds version of an interpreter yesterday. It's supposed to be used for code golf, but it currently can't do much. import re, functools, time stack = [""] * 9 def run(file): f = open(file, 'r') code = f.read() f.close() parse(code) def prompt(): """Lets the user input commands and ...
Can somebody help me make the code below smarter and free of redundancy? The code does exactly what I want, but I believe there are many redundant loops and arrays. from collections import Counter import csv import re with open("/Users/max/train.csv", 'r') as file: reviews = list(csv.reader(file)) def get_texts(rev...
Here is the Euler problem referenced, it says: The decimal number, 585 = 1001001001\$_2\$ (binary), is palindromic in both bases. Find the sum of all numbers, less than one million, which are palindromic in base 10 and base 2. (Please note that the palindromic number, in either base, may not include leading zero...
What do you think about quality of code in this method? It should: Generate new key based on keys in array The key should start with "TG" Code should find the max number in array keys with "TG-" and increment this number It should have 7 digits No need to check what if there is a key TG9999999, and what if array is em...
This is the Save function on my PurchaseOrder model in my real world production system. This code needs to write the state of the model to the database schema. It's grown over time as things have been added, so I'd like to work it a bit cleaner. As you can see, it's gotten very messy and is hard to work with now. Do yo...
I need to create matrices that follow a specific format: the matrix is a square NxN matrix and the off-diagonals all have the same value (param) and the diagonals have values such that the rows sum to zero (in other words, they are equal to 0 - param * (N-1). The output is a numpy array Here is my code. Is there any wa...
So I have part of a library which deals with scopes in Google+ integration, and I'm curious on the overall view of it. Yes, things are stringly typed in one of the methods, that is because this has to be COMpatible, which does not support enum's. I have (purposefully) omitted XML documentation, as most people think I g...
I am trying to turn my code into a working library (my first). Currently you simply call GridNav() and it sets up and executes. I am currently refactoring out all the necessary variables. The trouble I am having is the animations property. I want users to be able to override the property. (function(window, document, $,...
This question is a spiritual successor to Console class that handles multiple buffers. I was mostly interested in implementing one of the suggestions of using an iterator range and fixing the interface for Terminal. That means most of the code will be absent. Also, while the code above is intended for a freestanding en...
Inspired by this question, I modified the script to run a simple simulation of Taylor-Green vortex using LBM and post-processes it using P5*js (an official Javascript port of the Processing API). Unfortunately, it is not performing well, but as I am new to Javascript programming, I lack the insight to really optimize t...
I've written a program to find the odds of either side winning a battle in Risk, and how many men they would have left. I've finished, but I feel that it can be improved since it doesn't function if the battle gets too big (with "too big" being ridiculously small, to the point of being near-useless). Can anybody find a...
After reading about Strand Sort on Wikipedia and testing the provided Python version, I decided to try my hand at a faster implementation. I've studied the "Time Complexity" page, read many different approaches to mergesort (and borrowed some), tested the code myself with profiler, line_profiler, and timeit, and I thin...
I am trying to give show a UI friendly dump of the cache status <h1>Cache Status</h1> <table class="tables dataTables"> <tr> <th>Cache</th> <th style="text-align : center;">Created Time</th> <th style="text-align : center;">Last Updated</th> <th style="text-align : center;">Last Hit</th> <th style="text-alig...
A more proper version of this utility can be found at the following link here: Giveth me thy easier user input in C++ - follow up. I've always been a little bothered by the fact, that in order to get user input in C++, one had to use up to three lines of code in an ugly manner like the below to get user input for a sp...
I have two lists of Strings and two lists of objects. I need to copy the list of strings to the correspondence list of objects with specific values. public List<Name> retrieveCitiesAndCountries(){ List<String> list1 = new ArrayList<String>(); //list of cities List<String> list2 = new ArrayList<String>(); //list of ...
I don't know what is the common name for this data structure I named it like this due to a definition in wikipedia that states the following: In a 'multiply linked list', each node contains two or more link fields, each field being used to connect the same set of data records in a different order (e.g., by name, ...
I came across a question at the Udacity Intro to Computer Science course: Define a procedure, find_last, that takes as input two strings, a search string and a target string, and returns the last position in the search string where the target string appears, or -1 if there are no occurrences. Example: find_last('aaaa...
I created functions to read bit data from arbitrary bit position of a char array to long long int, and I also created a function to write data to a char array from vector bool. However, I do not really like my implementation since I think it has a burdensome implementation when reading and writing bits. Can anyone see ...
I asked this question first on StackOverflow but I didn't get an answer and was advised to try here too. So here we go. I have implemented Kadane's algorithm for a 2D array in Python 2 with known boundaries, but I'm using the implementation for an online contest and the time it takes is more than the time given. So tha...
Genetic drift — along with natural selection, mutation, and migration — is one of the basic mechanisms of evolution. In each generation, some individuals may, just by chance, leave behind a few more descendents (and genes, of course!) than other individuals. The genes of the next generation will be the genes of the "l...
I am using the universal selector in CSS: #containerDiv.containerTable tr td * { max-width:240px; } But Visual Studio suggests: "Performance: Never use the universal selector. It has a big negative impact on browser rendering" Will this have such a big impact? If so how can I overcome this? I have used * before an...
This is a follow-up to System backup on Linux. I've done a lot to my script since I asked my first question and I think I could improve a lot while doing this. The script still does the same, only a bit neater and cleaner. So let me explain what I changed, and sometimes why I've changed it. At first I changed all the ...
I'm new to F#, so I've ported an old Python script I have to F#. It scans a directory for files named something like Game.Of.Thrones.S01E02.xvidblahblah.mp4 or The_Wire_s03e04.somethingelse.avi, and renames them to a nice form like TheWire_s03e04_Hamsterdam.avi (where Hamsterdam is the episode's title, found from a web...
I'll be honest this isn't all my code, I have made some tweaks to bring it more up to date. The main goal is to do some browser detection and add classes to whichever element we want. I am simply looking for your input regarding the code. // Detect browser and add appropriate classes to calling element, typically 'html...
I am very new to matrix math. I have the following that sets the rotation in a 4x4 matrix. It is pretty ugly, so can anyone suggest how I could clean this up? I would like to not have to call MultiplyTwoMatrixes twice. A better way of copying the 3x3 matrix into the end 4x4 matrix would be nice as well. void MultiplyTw...
I wrote the following code to get the translated string from Resource Manager. The method GetTranslatedString is called more than 50 times in my project. public static string GetTranslatedString(string input, string culture) { if (string.IsNullOrEmpty(input)) return input; string retInput = input;...
I have two datasets: A list containing about 4200 string elements A list containing about 119,000 string elements I'm taking each element from list 1 and looping through each element in list 2 using the jaro-winkler algorithm to find a "good" match based on a desired confidence threshold. I know that this process wil...
Given an array of numbers I've to write a function to return the string "Arithmetic" if the sequence follows an arithmetic pattern or return "Geometric" if it follows a geometric pattern. If the sequence doesn't follow either pattern return "neither arithmetic and geometric". I'm a beginner and I thought of following s...
My first real program in python, so probably needs a lot of work. I've been taking a class and it's really slow and I was self taught most over past 2 weeks. Anything I should do differently? #Programmer: Delirious Mistakes #Date: October 7, 2015 #File: Advanced Shape Calculator V1 #This file will calculate the measu...
Following this post and this other post here we are with another review request. The code that follows contains the definition of logic gates (binary gates like the AND, OR gate, and unary gates like NOT). They are a part of an open-source application I have started to build. I'm following the Observer pattern to build...
I want to make class to retry doing what I want if specific exception happen for n times before throwing exception, so I write below class and used Builder to build it could you please review it and update me with your feedback: public class Retry implements Runnable { private final long sleep; private final Runnable r...
I've been toying around with Unity 5 lately, and in an effort to start making an actual game, I've built a ball controller similar to the one found in the Unity tutorial Roll-a-ball. In essence, the player controls a small ball that rolls around a "level". The ball can accelerate at a rate in the range \$1\rightarrow10...
I am trying to improve the performance of my scraper and plug up any possible security leaks (identifying information being revealed). Ideally, I would like to achieve a performance of 10 pages per second. What would I need to do to achieve the biggest performance boost besides get a faster connection / dedicated serv...
I'm multiplying 4x4 matrices for learning purposes. How can I optimize this for performance? HTML <table class="matrex-1"> <tr><td class="0-0">-1</td><td class="1-0">0</td><td class="2-0">-1</td><td class="3-0">0</td></tr> <tr><td class="0-1">8</td><td class="1-1">-9</td><td class="2-1">8</td><td class="3-1">-9...
I wrote a little function to create a sorted-map with vectors of coordinates as keys and an empty map as a default value: (defn empty-board [rows cols] (into (sorted-map) (for [x (range cols) y (range rows)] [[x y] {}]))) Is there is a more idiomatic way of achieving this?
I need to make a matrix (in the form of a numpy array) by taking a list of parameters of length N and returning an array of dimensions N+1 x N+1 where the off-diagonals are symmetric and each triangle is made up of the values given. The diagonals are equal to 0 - the row sum of the off-diagonals. I don't really like ha...
I'm just starting to learn CoffeeScript and am trying to work through simple examples, this one being Prim's algorithm. I'd like feedback on everything but especially on making this script take advantage of the features of CoffeeScript most effectively. nodes_dir = { 0 : [1], 1 : [0, 2, 3, 5], 2 : [1, 4], 3 : [1, 4, 5]...
So I am a newbie obviously, This was part of a small assignment I had to do for Uni, and it works alright. It just reads a number from the console and then outputs the Greek letter Φ (sort of). Sure it could use some outofbound exceptions etc, but my question is this: My code overall (not just in this example) seems a ...
I have an array of this fashion: var arr = ["akira",9248,"padilla",100]; I'm using filter to take the names and the points: var names = arr.filter(function(e,i){return i%2 == 0}); var points = arr.filter(function(e,i){return i%2 !== 0}); Then I do this to obtain turn it into object: console.log(JSON.stringify(_.objec...
I implemented Project Euler problem 40 in Java. It works correctly, producing the correct answer. During the course of implementing this program, I wrote a method that directly calculates a digit of Champernowne's constant, as opposed to the obvious brute-force approach. While brute-force is fast, this method takes und...
This is the first couple lines of my new (will be) 8-bit co-op horror game. This is just the code for the first player text-based adventure storyline for the console game. Please critique. //Andrew Tew /* First EVER Co-Op Horror Game! */ #include <iostream> #include <string> using namespace std; int main() { //Decla...
Attack-Rooks is a challenge proposed by ACM-ICPC as a variant of the N-Queens problem, using Rooks instead of Queens. Of course, to disallow the trivial "fill the diagonal" solution, pawns are used to block the rooks from capturing each other. Given a NxN (N > 0) chess board containing some pawns, output the highest p...
The problem is to find out the squares between two numbers, inclusive of the numbers. The two numbers are in the range between 1 and 109. long numberOne = in.nextLong(); long numberTwo = in.nextLong(); int count=0; for(long j=numberOne;j<=numberTwo;j++){ double numSqu...
This appears to work. Are there any edge cases I am missing? What are your thoughts on the algorithm and implementation? template <typename el> void Linkedlist<el>::reverse() { Node<el> * oldHead = head; Node<el> * tailAfterReversal = recReverseList( head->getNextNode() ); oldHead->setNextNode(NULL); ta...