instruction
stringlengths
71
71.9k
I have a string like "food | dairy | milk". The string may consist of more or less words. How do I turn it into a dictionary {'food': {'dairy': {'milk': {'eco': {}}}}}? The only way I could achieve it was to create a string and then turn it into a dictionary using exec. I understand it's messy. How could I improve on i...
My current project uses a database represented as object. Furthermore I want to implement methods like CreateUser(), DeleteUser() etc, but my current code requires the injection of the db-object as parameter in each function. Making the db-object global would solve the problem, but I learnt that global variables are mo...
I have this sorting algorithm which constructs an (unbalanced) tree and performs in-order traversal in order to sort the requested range. However, the more order exists in the input array, the closer to time complexity of \$\Theta(n^2)\$ it will get, yet it runs in \$\Theta(n \log n)\$ on most randomly generated arrays...
The question might seem a little bit long, but I will be very glad if you have read it till the end and told me your opinions. Let's say I have such entity: public class FirstEntity { public int Id { get; set; } ... public virtual SecondEntity SecondEntity { get; set; } public int SecondEntityId { get;...
This is again a solution to the codeEval challenge #1. It was accepted by codeEval, but please let me know if I can improve it anyway somehow? #include<iostream> #include<vector> #include<fstream> #include<string> #include<chrono> struct input_rec{ int first; int second; int last; }; void parseRecord( std...
One of the ways I learn a new scripting language is to implement a subroutine to convert a network MAC addr into the IPv6 link-local address, as described in RFC 4862. So here is a quick few lines. My question to you is: can this code be shrunk any more? is there a more pythonic way of doing this? is there anything n...
I have an unoriented graph with n vertices and m edges, 1 <= n, m <= 100000. All edges have 0 or 1 weights (two vertices are connected even if the corresponding edge has 0 weight). Vertices indexing starts with 1. I need to find length of the shortest path from vertex A to vertex B. Input data example: 4 5 1 3 1 2 1 2...
The community challenge for this month says: Everyone has played Battleship. Let's implement the logic that sinks one. But that presumes that there's something to sink. We can't have the armada turn its guns on itself out of boredom. So I figured I'd write something that could randomly place ships on a Battleship gri...
I wrote a little program that recognises poker hand combinations and compares hands if the ranks of both hands are the same. I had tested my program on possible combinations for each rank and the outcomes were correct. I would like to know how it is possible to improve the design of my code and maybe cut a few steps. I...
I'm using a Promise chain to write some data to a file, execute a command on it, inspect its results, and send the results, using Express.js. The thing about my function is that I need to be able to exit early from multiple conditions. The following code comes from an Express.js handler. my-command is a command that ta...
Some time ago I found a website about the Java Nashorn API which allows you to run JavaScript from Java code. I thought about creating a JSON parser in pure Java (without external libraries) which makes use of this API and the JavaScript function JSON.parse() My goal is to make this parser as fast, resource efficient a...
In preparation for the May 2015 Community Challenge, I decided to build a Battleship strategy tester. Implementing an ocean First, there is an underlying Ocean class that represents both the 10x10 grid that is the playing field. It has an internal representation for both the grid and for the ships that are placed on...
I've made a "heightmap" terrain generator similar to my previous one, except this one has some improvements, and some new features. The way this one works is similar to my last one, but slightly different, so I'll run through it again. First, a list of NoneTypes is generated with a set width and height. Next, the gene...
I just finished up a program which takes a byte[9][9] as input and recursively does a DFS to find any solutions (including multiple solutions). I'm pretty happy with it and it works pretty quickly as far as I can tell. I'm mainly looking for advice on the algorithm I used and its efficiency, as well as the way I handle...
Given the problem: You are provided a list of N elements all initialized to 0, and a list of M operations. Where each m in M consists of 3 elements a, b, and k. For each m in M add k to all indices in the range [a, b]. At the end of all M operations print out the max. I have two implementations, one of which is faste...
#include <iostream> template <typename T> class my_smart_ptr { T* raw; unsigned * p_count; public: my_smart_ptr(T* t): raw(t), p_count (new unsigned(1)) { } my_smart_ptr(const my_smart_ptr<T> & p): raw(p.raw), p_count(p.p_count) { ++(*p_count); } const my_...
I have created a sample file reading program as an exercise while learning how to implement good exception handling. I want to ask: is this a good approach or is there some other solution that I am not aware of? import java.util.*; // Needed for Scanner and InputMismatchException import java.io.*; // Needed for ...
The script reads WLAN packets, looks for probe requests and then extracts SSID, MAC address and then stores them in a list if the MAC address/SSID combo is unique. if p.haslayer(Dot11ProbeReq): if pc == 0: print O+'[+]'+W+' Got first packet! Many more to go...\n' if p.haslayer...
I have this tiny library for building unbalanced, binary trees and doing tree search on them. I tried hard to define a generic API that would allow custom implementations of trees. AbstractBinaryTreeNode.java: package net.coderodde.graph.tree; /** * This class defines the API for a binary tree node. * * @author Ro...
I have written a reimplementation of cat that will be compliant with most scripts, and that is as small and fast as possible. Can anybody suggest some size improvements for it? #include <stdio.h> /* we need printf, fprintf, FILE, * fopen, fclose and that sort of ...
A little look on what are Dictionaries: dictWordCounter<string, int> dictWordPercent<string, double> topTwentySeven<string, double> WordCounter is the number of words. For example, if the word frog is 10 times it will be {frog, 10}. WordPercent is the percent after some math in the program. For example, frog could b...
I am trying to learn how to use ASP.NET Identity. My scenario is that I have to authenticate against Active Directory. For that purpose I am trying to use ActiveDirecotoryMembershipProvider. What I have to do is: Authenticate user/password against Active Directory Check whether user is present in my own database The ...
I have the following data: trains is a dictionary with 1700 elements. The keys are the IDs of trains and the value for each train is an array with every station ID where that train stops. departures is a dictionary with the same keys as trains, so also 1700 elements. Each value is the departure time of the train. Now...
I have the following code, I use this pattern for the entire JavaScript code. I'm trying to re-factor my code again. Should I use the Module pattern? Revealing Module Pattern to be specific? What's happening is, somewhere in my code I say Dnianas.Notification.init(). First I bind the events, and I will handle them one ...
I'd like to know if it's ok to write like this or there is a better, prettier way to do this. The merging itself is ok. I'm more interested in dealing with the situation when one of the arrays is finished and I need to copy the rest of the other array to the result array. I wrote it in a try catch block. int[] result =...
I'm trying to learn Java (albeit rather slowly). I'm in a computer science class at my highschool and I've written this little bit of code for a project. Basically it is a word guessing game where if you get a letter correct it reveals it. If you get a letter correct in the wrong spot it marks it with a +, and if the l...
I just started learning commands for batch files. I figured a project is a good way to learn the language better, so I'm attempting to recreate the text-based RPG, Thy Dungeonman 3. So far, I've learned a lot from fixing a lot of minor problems such as lack of quotation marks, extra spaces at the end of environmental v...
I just read and experimented with C++ implementation of the merge sort algorithm from the Wikipedia page. During the experiments I have slightly modified the source code and would like to know how much the algorithm is improved (if it is). //! \brief Performs a recursive merge sort on the given vector //! \param vec Th...
I have a function that compares the values of a tuple and a list of equal length. It compares each value in combination to see if it is equal to its respective value in the path or if the value in combination is '*', that is valid. So for example: combination=('dog', 'cat', '*'), path=['dog', 'cat', 'bird'] would retur...
I'm currently using this pattern in my JavaScript code. Somewhere in my code I use Dnianas.Post.init. init fires and it will bind DOM events. At first everything was OK. But then, when you look at likePost method you will see that, I'm not using the var keyword to declare my variables. Because I if do that, then it won...
Now that I have some infrastructure in place to test it (see my Battleship test framework and the updated GitHub project for the full context), I have finally written a non-trivial bombing strategy class for the May 2015 Community Challenge. The SmartRandom class guesses randomly until it gets a hit. It then checks fo...
One day I saw a question on Stack Overflow asking about changing numbers to words, I thought about it, and next day I started coding. When I had the code working, I thought it could, most likely, be much better. Then I started looking for some existing code about it and found this one. I wasn't able to understand much ...
I've made a simple in-browser syntax highlighter using JQuery. It's pretty simple, it just wraps keywords, integers, and such in <span> elements with color styles. "use strict"; /** * Replaces any JS code with * highlighted JS code. */ function colorJS(element) { $(element).html( $(element).text() .replace...
I created this for a project at class, and I already turned it in so I know it's too late for changing it and whatnot as it's the end of the semester, but I want to know from the community how well I did. Don't judge all the std:: stuff. I built this using using namespace std;. #include <iostream> #include <fstream> #i...
I recently started learning Swift through Stanford iOS8 Course. The first assignment is to add some features to simple Calculator which was presented during lectures. List of tasks: add button for entering decimal point (appendDot()) add sin, cos and Pi operations add Label which shows history of performed operations ...
I have some JS that I am not OK with. How can I reduce the amount of code? (function ($) { var allPanels = $('.accordion-modal > dd').hide(); $('.firstlink').addClass('green'); $('.firstlink > header').addClass('green'); $('.accordion-modal > .active-accordian').show(); $('.active-accordian').add...
I am going through some CodingAbbey problems to learn basic programming tasks, with a focus on taking input from a file, and saving to another. I have just completed this task: Of two numbers, please, select one with minimum value. Here are several pairs of numbers for thorough testing. Input data will contain number ...
I developed this grid which displays number of records for X & Y, user can click each number to see a list. (I didn't add list markup to fiddle yet - so lets not worried about it for now.) What I believe is that I overcomplicated this simple project by choosing SVG, and it can be improved massively by using simple HTML...
In my PowerShell script I'm trying to delete a folder, but only if it exists: if (Test-Path $folder) { Remove-Item $folder -Recurse; } I find myself repeating this combination of cmdlets quite a few times, and wished I had something like this: # Pseudo code: Remove-Item $folder -Recurse -IgnoreNonExistentPaths Is the...
Mod note: This question is being discussed on meta I tried to create a method, that given 3 int numbers and a bool returns true if they are in strict increasing order (by the same amount) like (1, 2, 3), (3, 7, 11) or (0, 4, 8). Except if equalOk is set to true, then equality of two adjacent elements is allowed, such...
I have a class for making datastore inserts with Google App Engine and WTForms. Now I want to refactor it into smaller units but I'm not sure how to do it. Can you help me find what needs to be done? The code consists of code for taking a form (AdForm) and its parameters to make a datastore insert. It also checks for i...
I have a script that alerts me via email when a partition grows past a defined threshold in one hour. My script is run from cron hourly. Everything seems fine for 99% of the time, but occasionally I get an email from my script stating that growth in the past hour is something like ".08%", well below my current threshol...
Full text of the problem Using names.txt (right click and 'Save Link/Target As...'), a 46K text file containing over five-thousand first names, begin by sorting it into alphabetical order. Then working out the alphabetical value for each name, multiply this value by its alphabetical position in the list to obt...
I have a program that reads in two xyz-files (molecular structures) and compares them by an intramolecular distance measure (dRMSD, Fig. 22). A friend told me that my program structure is bad, and as he is a programmer while I am not, I guess he is right. But as he has no time to help me much, I thought maybe some one ...
The next iteration is here. I have this small method for printing long integers neatly. For example: neatify(123L) = "123" neatify(1234L) = "1 234" neatify(12345L) = "12 345" . . . The code: import java.util.Scanner; public class Main { public static String neatify(final long number, ...
I was hoping I could get some feedback on performance of my animations overall. It could just be me but I keep getting a bit of lag despite being at 60FPS constantly. Objects on screen seem to tear a little bit. Here's my code in full. Here is my game loop: //clocks and times used to get custom game loop working sf...
I have been working on a web-scraping Reddit bot in Python 2.7 with the premise of going to /r/eve (a game sub-reddit) finding posts that contain a link to a website hosting killmail information (basically combat logs in-game) and then replying to the post with the TL;DR of the log. Can anyone take a look at my code a...
Place N amount of queens in such a way that none of them can attack each other. import java.util.*; public class NQueensRewrite { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.println("Enter amount of queens"); int n = input.nextInt(); i...
See the previous iteration. At this point, I have "digit group" length assumed to be always 3 the user can pass the delimiter character of his/her own handles (seems to handle) the minus sign gracefully hacked away a test in a conditional import java.util.Scanner; public class Main { /** * Handles <b>most...
This was the exercise: Exercise PSD Think about a number under 25. Write down the number. If the number is even, divide in to two en write down the result below. If the number isn’t even (the number is odd) multiply the number with 3 and add 1. Write down this number. Repeat until the answer is 1. Write the code...
I have an object that I am populating via mapping and lookup with Reflection: this.SearchResults = (from a in response.postings select new SearchResponseModel { Id = a.id, TimeStampDate = a.timestampDate, ...
I want to change all values in a multidimensional dictionary. I have written this line of code, which does what I want it to do and I am trying to find out if this is the optimal way or just some convoluted solution I came up with: dict_data = dict([x,dict([y, dict_data[x][y]+100] for y in dict_data[x])] for x in dict...
The challenge, from Tour of Go, "Exercise: HTTP Handlers": Implement the following types and define ServeHTTP methods on them. Register them to handle specific paths in your web server. type String string type Struct struct { Greeting string Punct string Who string } For example, you should be a...
Any suggestions on how to improve the code shown below for the Go-tour exercise? Exercise description: There can be many different binary trees with the same sequence of values stored at the leaves. A function to check whether two binary trees store the same sequence is quite complex in most languages. We'll us...
I've got a program in Java which simplifies input string using grammar-like rules. Length of string is up to 200 and number of rules is up to 300. In big cases it works too slow, so I need some advice on time optimization of the code. Example input: 4 4; a b a b; a b -> b; a b -> c; b a -> a; c c -> b Program show all ...
I wrote the following function in PHP to represent IPv6 addresses as short as possible: function ipv6_compress($ip){ // Shorten first group of zeros if(substr($ip, 0, 4) == 0000) $ip = substr_replace($ip, '0', 0, 4); // Shorten full groups of zeros $ip = str_replace('0000:', '0:', $ip); // Remove le...
I am writing an application that consumes a JSON web-service in Python. I have an outer loop and inner loop, my inner loop is pretty ugly; how can I codense this to function more like my outer loop? By elegant, I mean performs the same functions without as many lines of code. items = [] for sr in decoded2['Response'][...
I am getting Out of Memory errors when I try to parse through a large CSV file (2.5Gb). My computer has 32Gb of Memory but Perl uses all of it up. The CSV has 2 columns. The first is the time in epoch and the second is a 10000+ line XML file as a single-line. There are around 13k rows. I then use XML::XPath to retriev...
My task is here as follows : Input : A complex/nested JSON object with nested arrays as well objects Output : A JSON object that contains a set of URLs with their titles: ( key,value ) pair eg {"Title1":"URL1","Title2":"URL2"} In this code, I simply go through the JSON object battle. My task is to append all the...
I'm fairly new to Java and tried to recreate a Bejeweled game, what I've coded so far works as intended, but I'm not sure if my approach is smart. I set up the board with new gems, but by doing this randomly, patterns (multiple gems of the same colour next to each other) can occur. That's why I recreate the board if th...
I'm implementing an Entity-Component-System. Basically, an entity is a wrapper around an ID, a component is just a POD struct, and a System is a class that does work on components corresponding to the Entities subscribed to that system. I'd like to take advantage of smart pointers, so the cleanup will be much smoother....
I have created many sites that requires php and html. They all work fine, but I'm now thinking if all that time I do it in a wrong way. Usually, first I build the site template, then styling and last I code php. Then I just include the php functions etc in the HTML. For example take a look of a table that lists some...
I am in the process of making an assembler and one of the needed steps is actually getting the opcode from a table. However, the instruction set I'm working on has a handful of different addressing modes which give different opcodes. On top of that, even if you have the same mode the parameter size changes the opcode a...
I would really appreciate some feedback on the code I wrote to solve the following problem: Design an IdManager. IdManager manages a pool of integer ids. (from 1 to n). It should provide api’s to get_id() and free_id(). get_id(): It returns any id , available in the pool. An Id cannot be given away again, unless ...
JavaScript is my first programming language, and I'm still pretty new. I'm just looking for feedback. What can I do to make this more efficient and handle larger numbers? // Project Euler - Smallest Multiple // This program finds the smallest positive number // that is evenly divisible by all numbers between 1 and n. ...
I'm hoping I could get some help in understanding as well as optimizing code! I've been working on a few exercises on some online resources, and I decided to try and take it to the next level and start using methods. import java.util.Scanner; public class SpaceBoxing { static Scanner keyboard = new Scanner(System...
My goal is to return a specific sentence in a story that contains a given word. Returns null if the word is not in the story. I'm ok with returning the first occurrence if there are multiples. Is there a more efficient or cleaner way to do this? public static String getSentence(String text, String word) { String se...
I've written an image resizer / uploader, that takes an incoming image, resizes it, and uploads it to the server, under the /usericons/ folder. However, the code is sloppy. Can somebody suggest a better method / improvements? define ("MAX_SIZE","400"); $errors = 0; if ($_SERVER["REQUEST_METHOD"] == "POST") { $image...
I've been working on my own dynamically-typed, dynamically-scoped, imperative programming language called Honey Badger and feel that it's reached a stable enough state that I want someone else's eyes on my implementation of the interpreter. For context, I'm going to walk you through a sample program in the language ...
The code implements custom iterator, which skips duplicate integers. The array expected is to be sorted. public class GenericIterator<K> implements Iterator<K> { private K[] array; // Array will be set here private int index; GenericIterator(K[] array) { this.array = array; index = 0; ...
I attempted some (easy) coding with Java Native Interface. This is what I have: six_pack_Neatifier.h: (autogenerated by javah) #include <jni.h> #ifndef INCLUDED_SIX_PACK_NEATIFIER #define INCLUDED_SIX_PACK_NEATIFIER #ifdef __cplusplus extern "C" { #endif /* * Class: six_pack_Neatifier * Method: neatify * ...
I have created an Odds Calculator in Java. The program gives me the odds, but I want to make sure that they are correct. Maybe someone can tell me a calculator I can compare my results with or knows another way to check if the odds are correct? With the calculator you can set your own hand plus the cards on the table. ...
Problem Statement This problem is a programming version of Problem 3 from projecteuler.net The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of a given number N? Input Format First line contains T, the number of test cases. This is followed by T lines each containing an integer N. Output...
input 3,5 output should be 3,4,5 input 5,3 output should be 5,4,3 And the code public static void test(int a, int b) { if(a>b) { for (int i = a; i >= b; i--) { System.out.print(i + "\t"); } }else if(a<b) { for (int i = a; i <= b; i++) { ...
I was given this exercise: Build a game in which two players compete in a game of Rock-Paper-Scissors with different strategies. Who will win more rounds? The rules: Scissors beats Paper Rock beat Scissors Paper beats Rock If both players choose the same, the round is counted as a tie. Implement two players: Pl...
Given a list of 250 words of 4 letters each, what is the fastest way, in Python, to find a subsample of 100 words (drawn without replacement) so that the distribution of letters across the whole sample is most even? List of words: http://pastebin.com/2kpiNAcC Note there are only 18 different characters, and some occur ...
This is a task from lab classes at my university. Problem statement was to showcase following features: Multiple activities in app. Passing data from one activity to another. Changing behavior of back button in one of activities. Getting picture from camera and displaying it in app. Binding callback action in XML file...
I have created an inventory management sheet for a Lodge in Africa. The general conditions of the document are that it has to be easy to use, because the people who are using it are not very computer literate. I have generated a "generic" master document where I have pre-entered the items for sale in Column A, and th...
The program should accept a name of a country as input. It should then parse the Wikipedia page for that country and find all links to the wikipedia pages of other countries on that page and make a list of all such countries. For example, if the argument was India and http://en.wikipedia.org/wiki/India has links to wik...
Chandan got bored playing with the arrays all the time. Therefore he has decided to buy a string \$S\$ consists of \$N\$ lower case letters. Once he purchased the string, He starts formulating his own terminologies over his string \$S\$. Chandan calls a string str A Balanced String if and only if the characters of the ...
We have some BloomFilters (like a java.util.set without deletion) and we store them in ehcache (you can think it's as a java.util.Map): For example, Constant.BLOOM_FILTER_CACHE ehcache contains: key value aaa bloomfilter (of name aaa) bbb bloomfilter (of name bbb) ccc bloomfilter (of name ccc) If we call local...
I'm trying to generate a fresh XML file using Perl XML::Mini::Document. It's working fine, but I don't know whether it's the right way to do it. Performance is the problem for me; it takes more time when the when record count increases. Is there any other module better doing than this one in performance and easier way...
I've been going through some of the exercises over on exercism and this is one of my solutions: a basic RNA/DNA transcriber. I was happy enough at first but now, looking at it again, the solution looks very repetitive to me. The two methods below are needed because there are tests to ensure we've implemented them. It's...
I have a list of files, the files have the same names and are in various different formats like swf, jpg, gif and fla. Each swf may contain ONLY a gif image, it's possible a JPG image that does not have SWF, which should be listed. For example: file1.fla file1.gif file1.jpg file2.jpg The output should be: BasicDBObjec...
I needed to create a simple method that converts numbers in Base 26 (string) using, as expected, letters from a to z. But that's not all, this Base 26 needs to be One Based. Which means that there is no representation for zero absolute value and there is a representation for 26 absolute value. Let me show a example: In...
Please look at a small piece of code I wrote and provide some thoughts, critiques and any feedback you think is needed. The code is here along with the problem I have attempted to solve and I look forward to hearing all your thoughts on it. The Problem The surface of Mars can be modelled by a rectangular grid around w...
I have write a program to determine the color of last bean from a tin (char[] beans). "Beans" in a tin are only green or blue. The rule is: If two beans taken out are both greens or blues, put 1 blue "bean" back, else put the green one back. Repeat until there are only 1 "bean" left. I don't know whether my code is rig...
This is a wolfram language program I wrote for super-resolution, in this case meaning to guess at how to increase the the resolution, and so detail shown in a raster image such as a photograph. It uses a different but related approach to its predecessor, that I created some time ago: Super Resolution in the Wolfram Lan...
This recent question Print Consecutive numbers by comparing two parameters frustrated me because I could not find a convenient way in Java 8 to support the conditions that are required. I answered it in a somewhat cumbersome way for Java 8... (the non-stream part of my answer is "OK" in terms of usability). To reiterat...
Utility to calculate the square root of a number. The method also accept an epsilon value, which controls the precision. The epsilon value could range to any number including zero. I am expecting a general code review or if there is a better way to write the code. /** * The class MathUtil contains methods for performi...
I'd like to get an opinion on the code I've made for a Tic Tac Toe game in C++. I'm pretty new to C++ but I'd like to improve. I haven't been able to think of any improvements. One bug I'd like to figure out later is that if a user enters values that aren't two separate integers the program seems to loop as if stdin is...
Edit See the next iteration at Array slice type in Java - follow-up. I have this "slice" type for managing array subranges. It is kind of the same thing as Pythons slice notation, yet I did not add negative indexing (since Java's Lists don't do it). So, what you think? Slice.java: package net.coderodde.util; import ja...
This is in one of my AngularJS controllers: websiteService.get('websites').then(function(data) { $scope.websites = data; websiteService.get('groups').then(function(data) { $scope.groups = data; websiteService.get('websites_groups').then(function(data) { $scope.websites_groups = data;...
Here's a brief explanation of my method: Provide a string and parse it to HTML code respecting a specific format. The accepted format is: For dropdown menu : Test DropDown~Select:Options1; Options2;Options3--- --- For Text area: Test Text area~TextArea:text to display** I am inheriting this VB code from a legacy ...
Problem I need to convert a double to a std::string which contains no scientific notation and no unnecessary fillers. Using std::fixed with iostream yielded ugly results - extra fillers (0's). The closest working code I could get was to using sprintf("%g",...) and then dealing with exponentials, should they appear (be...
I am new to F#. This code is basically a port I did from C#. I am sure there is room for a ton of improvement, so how can I improve and make this more efficient? let SingleFIle (req : HttpRequestMessage) dirName typeDir (fileType : string) userName clearDir deleteExistingFile = async{ ...
Inspired by this question, I was curios, if I could solve it for large n. For n=6209, its fifth power overflows long and I decided to stop below such numbers. The current algorithm reimplements the one from the linked question (the description, not the code) and could use some optimizations (but I'm not asking specific...
I have an array whose members are arrays containing strings. Each array has 5 elements, some of which may be empty but always at the end of the array. The order of the strings matters because their hierarchical labels—call them catLists. I need all the longest unique lists, ie. some of the shorter catLists are containe...
I've been trying to simplify a search method in a project that I've taken over. Is it possible to make the code any cleaner than I already have done? purchase_controller#search (original) def search parms = search_params @purchases = [] if parms[:active].nil? active = false else active = pa...
This is my code for a simple rock-paper-scissors game. Users have the choice between playing against a computer or watching a "computer player" play another "computer player". The code for the computer vs computer mode isn't finished yet, so you must chose human vs computer mode for the program to work as expected. If ...