instruction
stringlengths
71
71.9k
This is my first F# program. It's a command line utility that takes a parameter containing a path to an height map bitmap and prints out this height map converted to JSON format. open System.Drawing let convertLine (y:int) (bitmap:System.Drawing.Bitmap) = [ for x in 0 .. bitmap.Width - 1 -> "\"" + bitmap.GetPixel...
Consider the following contrived data type: Building: int age, char* location, float quality The location is in the format "XXX-XXX" (exactly 7 characters). Goal: Serialize the object into a binary format and then deserialize the object to display (on console) the exact same building info as inputed by the user. For e...
About This is a SEDE query which will calculate your activity and participation on a site. It's geared for Programming Puzzles & Code Golf where questions are values more, but the values can be modified to fit general Q&A SE sites too. Try it online! So I did what all programmers do and I looked up how to most of this...
I really like Ruby and want to get better at it. Any input is appreciated. Description This program prompts the user for a string which is ciphertext resulting from a Caesar cipher given (English) plaintext and a key on the range [0, 25]. The program then uses a table of character frequencies of the English language to...
This is a program I made as I am currently living in Japan with a British bank account, so exchange rates matter to me. On the first time run, you run the script with two arguments (two currencies) and it will track those currencies. You can add as many exchange rate trackers as you like. It emails you daily (automated...
I have the following class which is used for operations on a vector. The vector stores the following struct which has 3 enums and 1 boolean. Info represents a computer node. Nodes communicate with each other. Some nodes are unique (in which case they don't have an ID (and others are not so they have a id associated wit...
I have an array (or string) to parse and I want to examine each element sequentially. This is a perfect case for the iterators / consumers that Rust offers. The problem arises when I have to access previously parsed data during iteration. For example, I need to subtract the item that was 5 places before the current ite...
Courtesy of a few posts around here I've discovered HackerRank. Poisonous Plants is one of their challenges. Of course, skip the following if you'd like to try it yourself. Challenge: There are \$N\$ plants in a garden. Each of these plants has been added with some amount of pesticide. After each day, if any plant has...
I have written a Python 2.5.4 function which accepts as input a list of numbers alongwith the desired number of classes and yields a frequency distribution (i.e. a histogram) of the same data. While setting class boundaries, I've attempted to increase the accuracy (i.e. number of digits after the decimal point). Here...
This question has a follow up question: Binary Search Tree insert while keeping track of parent for node to be added - iteration 2 I am implementing a red black tree for fun and am wondering how I should modify my basic BST insert. Note: this happens before the red black tree rules are applied, it just finds the corr...
The task is to return all root-to-leaf paths, given a binary tree (from leetcode). This is my approach. Take a helper array and a counter, keeping track of what has been traversed so far. If it is leaf node, print all till that point. Reduce counter. Please suggest improvements, if any. import java.util.LinkedList; i...
Follow up question to Binary Search Tree insert while keeping track of parent for node to be added I am implementing a red black tree for fun and am wondering how I should modify my basic BST insert. Note: this happens before the red black tree rules are applied, it just finds the correct place within the tree to add...
This is a continuation of An Alternative Vector, taking a closer look at the copy assignment operator. In the following code, I am only posting the new version of the copy assignment operator; all the rest of the code is unchanged. namespace ThorsAnvil { // Traits classes // SimpleCopyableAssignableTraitNo...
This is my version of snakes in C++ using the ncurses library. I would like to hear from you how this piece of code can be improved and general advice for future projects regarding coding and efficiency. I have tried writing this code in pure OOP, let me know about that too. #include<ncurses.h> #include<unistd.h> #incl...
I am teaching computing to an AS class and this was their assignment: Bush Wanderer Task 1 Create a 5x5 grid of hashes(#) where the player is an x on the board Prompt the player to move in either N, E, S or W direction and then reprint the board to show the new position. Example: x # # # # # # # # # # # # # # # #...
I’d love some feedback on this human v. human, tic tac toe game I wrote in Python 2.7.10. I’d love to hear your thoughts on optimization and making the code simpler and more “pythonic”. Also, I’m wondering if passing the player and turn variables around the way I have is the best approach, or if I should consider glob...
Overview: I'm using the following page template and scripts for navigation. I use a single page that loads menus and context content, and then use ajax or GET variable to load main-div's content, by passing $p variable to a php switch. Browser history is handled whith pushState function. Main page: <!DOCTYPE html> <htm...
I needed to create a mortgage calculator for an intro to CS class. As part of the assignment, with an interest rate of 6% needs to change to 7% after 3 years hence that if statement. The char dummy line at the end is a requirement from my professor. I'm mainly looking for ways to clean it up or if I missed anything. I'...
I am creating a way for users to filter results based on start and end values. An example of this would be: ?RangeColumn=DisplayId&RangeStart=640,830,670&RangeEnd=650,850,680 In this case, the api would return items where the "DisplayId" is between 640-650 or 830-850 or 670-680. My solution works but the query looks p...
I'm trying to implement union from the standard Data.List library. I know it's reinventing the wheel, but reimplementing functions is how I learn things. Any feedback at all would be helpful! union' :: (Eq a) => [a] -> [a] -> [a] union' [] _ = [] union' _ [] = [] union' xs ys = nub' $ xs ++ ys where nub' [] = [] ...
I am working on a Web Scraper for the first time using Test Driven Development, however I have caught myself into a huge CRAP (Change Risk Anti-Patterns) index (56) and I can not seem to find a solution about this. <?php /** * Code Snippet MIT licensed taken from proprietary source. */ namespace WebScraper; use Web...
I'm new to C, want to know if I'm doing this right. //repstring.c #include <stdio.h> #include <stdlib.h> #include <string.h> int main(int argc, char **argv) { //Initialize variables and pointers int i; int loop; char *deststr; char *str; //Change second argument to integer loop = ato...
I've been tasked to solve this exercise lately, and this is what I wrote: object Main { def isSubstringPalindrome(inp: String)(start: Int, end: Int): Boolean = (start.compareTo(end), inp(start)==inp(end)) match { case (0, _) => true case (1, _) => true case (-1, true) => isSubstringP...
Input The input for this problem is a String of sorted numbers and a special number. The syntax of the input would be 1,2,3,4;5 Output The program will output all of the possible sums that equate to the special number. The output for the example would be 1,4;2,3 I solved the problem by using some simple subtraction. ...
We have two lists: l=["a","b","c"] s=[["a","b","c"], ["a","d","c"], ["a-B1","b","c"], ["a","e","c"], ["a_2","c"], ["a","d-2"], ["a-3","b","c-1-1","d"]] print l print s Now, I am try to see if each 2nd-level list of s has fuzzy match to any of items in list l: matches=list() matchlist2=list() print s2 for i in ran...
I just started to learn D and ported my a bit over-templated trie. It looks way better than on C++. I'm sure there is still room for improvement and to make it be real D code. I checked an the array appending is doing x2 pre-allocation on resize (although 1.5 seems to friendlier, but for my use both are ok). Does this ...
I'm creating a simple popup to be shown on footer of pages to make a email list. I would like you to give a look at the code below if possible .. and would appreciate some suggestions in respect of the logic applied and the form of how the code was encoded. Live fiddle here var App = App || {}; App._elements = App._el...
Today I decided to continue working on a UnrealScript (Unreal Engine 1) class that lets bots jump onto ledges by firing weapons beneath themselves. (The only problem is that they don't aim and jump correctly, but as soon as this is fixed I'll edit.) Methodology: The Bot that wants to use the navigation node will call ...
I finished Codeacademy and I'm looking to practice and get better at JavaScript. Is this coded correctly or should I have made a function for it somehow? The purpose of this code is to move a square around the page with arrow keys or buttons. I have the entire script hosted here. I mostly want to "Simplify this chain ...
I'm trying to learn Golang from Java, and to do this, I wrote a basic circuit simulator with only two circuits. Is there anything I can do better to make it more idiomatic? Simulator.go package main import ( "fmt" ) const ITERATIONS = 10 func main() { a := Wire{false, false} b := Wire{false, false} c...
I have been struggling with understanding Model, View, Service, Controller architecture and wrote some code. Is my Model class the Model part of MVC (did I define it properly)? Is my Service class a Service Layer (did I define the layer properly)? Did I connect my layers properly (is the 'wiring' set up correctly)? ...
The Needleman–Wunsch algorithm is an algorithm used in bioinformatics to align protein or nucleotide sequences. Here is an implementation in Scala: package vu.co.kaiyin.akkconcurrent import vu.co.kaiyin.akkconcurrent.NeedlemanWunsch.{ResultEntry, Score, SimilarityFunc} /** * Created by IDEA on 2/26/16. */ case c...
So, I kept refactoring my Sage300 API wrapper - I wanted the client code to feel just like using Entity Framework - this is the closest I got to it: using (var context = new SageContext(/*redacted credentials*/)) { context.Open(); var header = context.PurchaseOrderHeaders.Single(po => po.Number == "NETAPI99")...
I need to parse a simple JSON string (flat JSON, no hierarchy) for keys and values, and there is a system constraint that I cannot use any built-in JSON library and can only read a string once due to latency requirements. I need to use Python 2.7.x series and cannot use a higher version. It looks a bit ugly and I'm loo...
I just wanted to know if this looks like a good way of reading a config file. Is this code good? Is it clean and easy to follow? <? /* class to parse a txt config file * * Boolean like string values (on/off, yes/no, true/false) will return true/false * Numberic string values will return real numeric ...
My code solves Project Euler problem #011: What is the greatest product of four adjacent numbers in the same direction (up, down, left, right, or diagonally) in the 20×20 grid? I looked over one of the interview questions for a job in my current workplace and came across this problem and tried to write a solution for...
The problem is taken from here. The tree is guaranteed not to have duplicate elements. My questions is, instead of creating new arrays leftInOrder, rightInOrder, leftPostOrder, rightPostOrder, I could simply pass the indexes to the same input arrays to the recursive function. Does that help in any way? Basically, any ...
I found creating radio buttons in my application a bit of a hassle in terms of having to configure the HTML to do what I wanted when the user clicks/unclicks the items etc. I figured reducing it to a directive was the best way to simplify things. The functionality I want is: Be able to pass in a list of items that are...
This is a jQuery function that controls a <div> to expand up or expand down. I am trying to simplify and optimize these lines of codes. Scenerio By default, it does not have any classes in <div class="title-wrapper">. When I clicked on <div class="title-wrapper">, it adds .expand-up into this <div> if there .expand-up ...
I have implemented a GUI for my sudoku solver: You can use mouse for operating it, yet I have coded moving the cell cursor with keys wW/aA/sS/dD. My code follows: SudokuGrid.java: package net.coderodde.sudoku; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; import java.awt.Font; import...
My friend wrote a scraper in Go that takes the results from a house listing webpage and finds listings for houses that he's interested in. The initial search returns listings, they are filtered by city, and then the details of each listing is acquired from a separate HTTP request and more details are checked to see if ...
I've been maintaining a Rbac helper for some time now. My goal is to provide an easy way to tell the following: When does an user have a role What can a user do (with those roles) Which users have which role in which resources And I'm pretty happy with my result so far, I can do the following: var rbac = new RbacSess...
I'm new to both Elixir and tail recursion. defmodule MyInteger do defp sum_upto(x, accumulator) when accumulator <= 1 do accumulator end defp sum_upto(x, accumulator) when accumulator > 1 do sum_upto(x, accumulator-1) + accumulator end def sum_upto(x) when x <= 1 do x end def sum_upto(x) do...
//repstring.c #include <stdio.h> #include <stdlib.h> #include <string.h> #define MAX_LOOP 99999 #define STR_MAXLEN 300 #define USAGE_INFO "Usage: repstring <argument> <string> <amount of times to repeat>\n\nArguments:\n-s silence length of string output\n-a add space inbetween every string\n" #define SILENT_ARG "-s" #...
I made a simple mp3 player that plays, pauses and stops a given song, shows the time elapsed, and has a volume control. I read the documentation and can't figure out the difference between the pause and stop methods, although I have configured them to work as I want (i.e., pause lets you resume from where you left off...
This is my revision from another post union' :: (Eq a) => [a] -> [a] -> [a] union' [] list = list union' (x:xs) list | not $ x `elem` list = x : union' xs list | otherwise = union' xs list Any suggestions welcome.
I wrote these two classes for teaching OOP in PHP. Do you think it's breaking some good practices or SOLID principles? <?php class City { private $id; private $name; private $districts = []; public function __construct($id, string $name) { $this->id = $id; $this->name = $name; ...
I have an HTML table and I use jQuery to fade some content for each TD: Demo My code works great, but I want to know if my solution can be better. <table> <tr> <td id="first"><img src="#" /><br />Inserer un produit</td> <td><img src="#" /><br /></td> <td id="second"><img src="#" /><br />Inserer un nv crédi...
I store ratings in a table called ratings. The table has these columns: id | user_id | value | ip | showcase_id value is an integer between 0 and 7 (the value of the rating). i.e. there is 8 different ratings to pick from. They are, in English: 7/7 = Amazing 6/7 = Great 5/7 = Good 4/7 = Decent 3/7 = Meh 2/7 = Poor 1...
I need to parse a simple JSON string (flat JSON, no hierarchy) for keys and values, and there is a system constraint that I cannot use any built-in JSON library and can only read a string once due to latency requirements. I need to use Python 2.7.x series and cannot use a higher version. Currently, my major concern fo...
I used CodeClimate to evaluate my code and marked that the following piece of code appeared twice in my source: except IOError as e: log.error("I/O error({0}): {1}".format(e.errno, e.strerror)) app_exit(1) The justification is that the amount of duplication mass is 33, which is above default limit ...
I am trying to refactor a ViewModel class because it has two methods that are really similar called updateRegions and updateTowns and even another one may end up being made called updateCountries. I basically copy-paste the method and change the variable names. How can this be refactored with maybe an abstract class th...
I wrote a function to resolve the full path to the current Bash script, and I'm wondering if it's SOLID: #!/usr/bin/env bash scriptpath() { result=${BASH_SOURCE[0]} # unfortunately readlink -f isn't available on Macs, # so resolve the symlinks manually while [ -h "$result" ] do symdir=$(di...
I've been working on learning Pygame and I made a Breakout clone. I'm looking for stylistic advice and overall suggestions for improvement. Controls are simple: - ← and → to move. # Breakout/Arkanoid clone import pygame, sys from pygame.locals import * import math # General game attributes FPS = 100 WINDOWWIDTH = 48...
I often use a ViewModel class that contains a collection of Contacts and allows me to iterated through the collection with Previous and Next buttons. I find that I've got duplicate versions of this class all over the place and I'd like to make my code reusable. How would I go about making the following code reusable (i...
The following regex is meant to improve stringmatching by sanitizing the user -defined commandPrefix and checking for whitespace and line-endings after the specified text. command will generally be a single word, hence not escaped. var prefix = commandPrefix.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'); return text.test("...
My experience in bash is... well, around the Bourne shell on AIX. I wrote a semi-complex script in Bash, and I feel that it could be improved in 100 different ways. The Github project is here: https://github.com/mercmobily/lapser Questions: Does anything stand out in terms of things done horribly wrong, in any way? In...
I've been learning Objective C for a few days so to test my skills I went ahead and made a simple Tic Tac Toe game using the console. I already have some experience with languages such as C++, Java and Python so I'm familiar with most of the concepts in Obj C. How it works The player chooses their token (x or o) The p...
I am trying to get a recycler viewer with a cursor adapter. I seem to miss important points, so my view gets some of the data repeated instead of all the data at once. Can anyone who knows about this issue review this code and help me find the problem? import android.content.Context; import android.database.Cursor; imp...
I would like to ask about possible improvement of this code. I have created very simple code using MVC pattern. Is there any logic or anything to change? I tried to keep MVC idea. This is model, class Customer: package customereditor; public class Customer { private int ID; private String name; privat...
I've discovered that Google Chrome on iOS doesn't fire the hashchange event when the back / forward buttons are pressed. Reference: https://stackoverflow.com/q/35620762/2948042 https://bugs.chromium.org/p/chromium/issues/detail?id=559122 To work around this problem, I wrote code that uses setInterval() to check locat...
I recently reviewed some code implementing some heuristics which has piqued my interest in the A* graph searching algorithm. I'm going to do that in a bit but first I need a way to create a graph in order to work on... I could have used Point from System.Drawing, but I didn't want to include the whole assembly for the ...
I found there are two methods to code an if-else statement with a timeout function. Two of these scripts work fine, but which one of them is more preferable and why? Method One app.controller("filter", function($scope, $timeout) { $scope.expand = function() { $timeout(function() { if ($scope.exp...
I have some code for checking a binary header to see if a binary file is meant to be read by a certain program, and I could use some extra eyes to review it. Assume the following typedefs: namespace Types { using Byte = std::uint8_t; // From <cstdint> using UInt32 = std::uint32_t; using String = std::s...
I have this project that should continuously animating using for loop. Also I want to include variations on the position where the ball pass through. Can anyone please check my code if I am following best practices in coding. Also feel free to edit my code and suggest me some refinements. Thank you. package movingball...
I created a slider that fades images automatically but you can also click to see the next or previous image. It already works how it should. But I think my code is really heavy. I am not experienced with JavaScript / jQuery so it would be nice if someone could help me to tidy up my code. // helper to change the slider ...
I'm writing a fastest-code challenge over at PPCG relating to base conversion of bases 1 to 36, and as a part of the process for writing the competition, I decided to write my own program for it. This is the code I wish to be reviewed: public class BaseConv { // Disallow instantiation private BaseConv() { ...
I've built-out a mechanism to go and find an auto-generated invoice and update it with new information when a plan is changed or if users are added to the plan for the current billing period. It will make it a lot easier than having to remember to change it a month, quarter, 6 months, or even a year from now. And this ...
I've some questions for an exam and wondered if somebody could take a look at my Fibonacci sequence that is supposed to answer this question: "select the element out of the array if its index is a Fibonacci number" def fibonacci_sequence(max_num) sequence = [1, 2] loop do fibonacci = sequence[-2] + sequence[...
I'm a first year college student, Computer Science major. This is my crack at the FizzBuzz interview question in Java. What kind of improvements could I make? //Prints numbers 1 - 100, 25 values per line. //Numbers that are multiples of 3 are replaced with Fizz //Numbers that are mulitples of 5 are replaced with Buzz /...
This program was inspired by a Code Golf challenge that I wanted to do properly. It simply converts oOo to Brainfuck and vice-versa. The oOo language basically uses UPPER / lower case information in groups of 3 to encode a Brainfuck program. For further info see the Esolang wiki page of oOo. The main problem with this ...
I have a bit of code that looks like this: for (Node n : g.getNodes().values()){ n.setPosition(new Position(new Double(lo.getX(new Integer(n.getId()))).intValue(), new Double(lo.getY(new Integer(n.getId()))).intValue())); } Essentially all I'm wanting to do is for each node in the collection, ...
I'm reading denormalized data with a SqlDataReader, the data has this form: SELECT Objects.ObjectName, Objects.OwnerId, Owners.Name FROM Objects INNER JOIN Owners ON Objects.OwnerId = Owners.OwnerId ORDER BY Objects.OwnerId Which has this output: OjectName OwnerId OwnerName Foo 1 ...
I am very new to Selenium, and for my current project, I had the task of creating the automated test scripts for our website. I am the only one on my team who had any experience with Selenium, but not any in depth experience. I also didn't have a lot of time to spend on this, as I had other work to do, so I didn't spen...
I am using idenity server 3 authentication. I have to implement refresh token logic. AccessTokenLifetime is 1 hour, and after that time I want to update access token with refresh token. I want do this only once, by using filter in mvc. My idea is to check if token has expired, and if yes that get new token. This is my ...
Any comments on this? Like there is a way to get rid of all the if-statements or a better way to # check model and build (which actually just prints the info out, so the comment may be a bit confusing) feel free to tell me what you think. MENU_MAIN() { clear ...
I have a class which creates a new match. My problem is that I am sure the code is unnecessary long and can get much improved (just keep in mind it is beginner level). Specifically, I would like to know: Can I change the below into 1 setter and 1 getter method? I would like to use the rand() function for match ID can ...
I had an assignment to create a table that will be stored in ROM (read only) and will be used in some algorithms (to convert numbers to strings). However sometimes a user will want to edit the table a bit before using it in the algorithms. So the user must be able to copy the table to RAM, change it and then use it. W...
I've been messing around with some stuff in Unity and are now working with 5 classes in my project. As I am very new to the engine, and even C#, I believe I made a rather messy code, even though it works as desired. I would love your guys personal opinions on how to clean up and organize my code, which I hope is okay t...
As part of my effort to learn JavaScript, I have started developing a small library for creating DOM widgets like modals, tooltips and so on from scratch (nothing but plain vanilla JS allowed in other words); much like jQuery UI. So far, I have only developed one widget, namely a modal, but the general structure of the...
I have this simple looping macro, but I can't seem how to figure out how to make it run faster. I tried including more update = false statements as well as well as removing any selecting type behavior. Sub AbesLoop() Dim wbk As Workbook Dim ws As Integer Dim Filename As String Dim Path As String Dim rCell As Ran...
I am a student doing their AS Computing course and I have created a piece of code in which a message can be typed and then scrambled by moving letters along the alphabet. I was wondering if anyone knew any way in which this could be improved. while(True): message = input("What would you like the message to say? ").low...
I came across a piece of code that generates SELECT queries from a template. The template: SELECT TOP 1 * FROM MRH_0000004 WITH (nolock) WHERE MachineRegisterId = ${id} ORDER BY UtcTime When the code has to retrieve multiple records, it generates one large query that gets the union of all individual queries base...
I made an adventure game, it is unfinished at the moment but not far off. Here is what I have so far: def Invalid(): print("Sorry I didnt understand what you just wrote") def Help(): print("The commands that I understand are:") print("Open, Take, Talk, Use") def Intro(): print("Welcome to my adventure g...
This takes two sets of five random points stored as a NumPy matrix, and then calculates the NumPy matrix between a point of the first set and a point of the second set. While the code works, I feel it's inelegant, as if I was writing in PHP or some other language. How can the function CalculateMatrixDistances be improv...
I have this easy en-/decryption algorithm. Disclaimer However, I have absolutely no prior experience in information security, encryption, and so on, so bare with me. Encryption Encryption works this way: first we read in four first bytes from the data being encrypted; then, we treat the four bytes as a single 32-bit i...
I created a following class to manage multithreading without extra overhead, which exist when I use Parallel TPL class. It is also useful for systems without TPL. Can it be enchanced? public static void Foreach<T>(this ICollection<T> source, Action<T> action) { var allDone = new ManualResetEventSlim(fa...
I have been solving problems on Timus Online Judge. In the beginning, I didn't worry much about I/O operations, so I just took some code from the internet and focused more on the logic. But after going through the helper class that I was using, I created my own class. This is the original stuff: import java.io.InputStr...
I wrote this class: public class MediaFile : IDisposable { private const int SECTION_SIZE = 8192; public string FilePath { get; private set; } public List<byte[]> Checksums { get; private set; } private FileInfo fileInfo; private MemoryMappedFile memoryMappedFile; public MediaFile(string fil...
I've been always updating my log methods, because I started SDL and I needed some new methods. First, I made difference between debug and release, and so console and file. But now I want a more powerful method, which handles the console with implicating the file, and works like C++ streams. I would like to know if it's...
My goal is to accept user input regex in the following forms /regex|here/i /regex|here/ regex|here From there I want to be able to pass that to a function and return a RexExp object for use later with string.match() I came up with the below to achieve that, and not break the caller which is expecting the RegExp object ...
I've written some classes to encapsulate the limits given for datasheet parameters, e.g. for the classic 741 op amp: As the above example datasheet snippet shows, there are some challenges for representing the values in the "min", "typ" (typical), and "max" columns -- including cases where there is no typical value, a...
I recently submitted a code-challenge for an interview according to the following guidelines: About Write a function or method that accepts two mandatory arguments and returns a result. Requirements: Use Ruby or another language of your choosing, and write production quality code. Your function or method should not us...
I have this code and at the end of it, FastMM shows that there were memory leaks with all the objects of TSinc: unit sinc_int; interface uses Classes, log_listener_list_int, tick_listener_list_int; type ISinc = interface; ISincList = interface; ISinc = interface ['{53814230-6308-4259-99FF-6054F2C91F9C}...
The goal for this code is to provide a semi-secure and privileged method of user registration via a secret code that is stored as a key in the Firebase database. Subscribers to a mailing list were all sent a 'secret' registration code. Upon completion of the registration form, RegisterFactory.register is called from th...
I want to write a program in Java that return a prime factorization of any natural number greater than one. After spending some time coding and debugging, the program runs fine. Since I am new to Java and programming in general, I don't know how bad my code style and class/method design are. Hence, I am here asking for...
My code currently generates a 2-variable truth table and lets the user select to AND/OR/NOT the variables. I was looking for advice on how to make it more concise, handle bad inputs better, and ignore case while going through. CODE: #include <iostream> #include <string> #include <iomanip> using namespace std; int main...
This code works for me, but I am trying to improve my coding and am looking for advice on how to improve it. Specifically I want to simplify this so that perhaps I can have a dynamically updating dataframe that tracks the "site" that I am on, and the "cutoff" value that I am on, and records the calculations for that si...
I've created a linked list template class which contains a copy constructor that performs a deep copy of the list. LinkedList.hpp template <class T> class LinkedList { protected: struct Node { T value; Node *next; Node(T val, Node *nxt=NULL) { value = val; next = nxt;...
I'm contemplating how to read an int using Scanner.nextInt(), and at the same time ignore the rest of the line or flush the input buffer to be ready for inputting the next number. Typical usage would be to read a number where the user is likely to add units or similar after the number, and I want the scanner to be clea...