instruction
stringlengths
71
71.9k
I need to split a list into equal sublists, e. g [1..9] split into groups of 3 will be [[1, 2, 3], [4, 5, 6], [7, 8, 9]]. I have accomplished this task in the following way: splitInGroupsOf n = takeWhile ((n ==) . length) . map fst . drop 1 . iterate (\(res, list) -...
"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 obtain a name score. For example, wh...
I'm back with a Python solution for Project Euler 35. Any help would be appreciated; I generate the numbers by observing that all circular primes can only have digits 1, 3, 7, and 9. Then I use the Cartesian product built into itertools. I also have a local primes test from Wikipedia. from primes import test as is_prim...
This one was quick and simple. Any optimizations? from timeit import default_timer as timer def sum_double_base_palindromes_under(limit): def is_palindrome(n): if str(n) == str(n)[::-1]: return True return False sum = 0 for n in range(limit): if is_palindrome(n) and is_p...
My project here works upon output that comes out of a Tesseract OCR scan using hOCR format, then I read it with JDOM 2.0 and finally save it one of my own objects, which at a later point needs to be serializable. I have spotted one major codesmell, which is a for-loop of 5 levels deep. An example hOCR output file: <?xm...
I was looking at other people code and I realized that mine is not so neat after all. In this version, I included a base case for the merge part (when there is only 2 elements to merge, just sort it normally). I do not know this is a good idea or not, never seen it in other people' codes. This is the first time I imple...
I created a client side search module. Could anyone please provide review pointers on it? var search = function(){ "use strict"; var _instanceMap = {}; var maxLimit = 50; //TODO: add a perf test to determine the scale. /** * @constructor * @private */ function _IndexCreator(_searchConfig){ this.ref = _searchCon...
I use the following code to find the lowest denominator Rational that is within a certain delta from a double. The rationale is that the I am pulling float numbers from a database and in many cases summing them. All of the numbers are calculated using simple maths such as +, -, * and /. No transcendental numbers are in...
I needed to have a Lisp function that could produce a string of a certain length, created by repeated concatenations of a another string given as argument (so for example by giving 10 and "abc" I could obtain "abcabcabca"). I came up with a perverse idea of using a circular list of characters in combination with the lo...
I've built a simple class RequestHandler that does exactly what I want without any extras I won't be utilizing. When needed I will expand. I'm passing this object to my Router class, to route URls to the correct controller. I will also take any suggestions! How is the readability? Good idea to make it a singleton? Ther...
I’ve recently coded a way of checking a 10-digit ISBN. I was wondering if the code works to check the numbers, and if there are any flaws in my code. def isbn(number): try: numberreal = number #keeps real number with "-" numberzero = number.replace("-", "") #this makes sure python do...
Is there an effective way, maybe with regex, to change the following text pattern? I have a string like abc_def_ghi_jkl. I want to replace it to AbcDefGhiJkl. I currently use the following code to change it. Is there a more effective way than this? implode('',array_map('ucfirst',explode('_',$string)));
Following my answer to Unique type ID in C++, I have worked towards a "safer" version that I am posting here. This is a lightweight type that can store a unique (also across compilation units) ID per type for use at runtime, without RTTI. Instead of using a built-in type for ID representation that is also accessible to...
I always been curious on how to build great application with proper routing to my controllers, but after seeing some sources of applications like Xenforo, Joomla, it seems completely different, and mostly I can't understand them. From my understanding the user sends a request to the web-server, the controller's job is...
I have written this Perl program to prove a conjecture given a set of clauses. I've actually posted some code from it on here in another question. This time it's all done, and I've made it as fast as I need to make it. Now, I want to calculate the Big O notation of the program. It's something I want to get better at be...
I created a DAO class which is base class for all other DAO classes. I use Spring Framework 4 and Hibernate 4. Question: Is there anything that could be done better? public class GenericDaoImpl<E, I extends Serializable> implements GenericDao<E, I> { private Class<E> entityClass; @Autowired private Sessi...
I am making a Swing application for light local database management and I have the button Run XAMPP. When that button is pressed this code is executed: private void jRunXAMPPButtonActionPerformed(java.awt.event.ActionEvent evt) { ...
Once you define the < operator, you can have an estimation of how the rest of relational operators behave. I'm trying to implement a way to do that for my classes. What I want is to define only the < and the rest of the operators to be defaulted implicitly. What I've got so far is this design, which I'll elaborate on ...
Question: Is there anything you could do in order to improve the test? I am using Spring Framework 4, Hibernate 4, JUnit 4. All DAO unit tests inherit from TestDaoSetup class: @ContextConfiguration(locations={ "classpath:/config/test/spring.xml", "classpath:/config/test/hibernate.xml" }) @TransactionCo...
I'm working on a Unix machine where I can't use more than vanilla Perl, and I'm using Perl5.8. This script exits with a 1 if the current directory size is smaller than 1 GB (the character after -d is a literal "tab" character). my $du = `du --si | tail -1 | cut -d" " -f1`; chomp $du; if (substr($du, -1) ne "G") { ...
Currently I'm making a website that has a to-do list that will probably become quite long to write in html. So I decided to make a shorter version for me to write that I find more comfortable to read. What I am currently doing is using ajax to read the text file from the server. Once the file has been stored into a str...
I have created a console program where users type in a math equation such as 5+4-6 or (5+16(8-4))/16 that follows order of operations. The equation is sent to a char array that is then parsed. If a # or . is encountered, the char is placed into a buffer. The buffer is tokenized into a token class, followed by the opera...
Here's how I implemented concat - flattens a list of lists into just a list of elements. concat' :: [[a]] -> [a] concat' ys = foldl (\acc x -> acc ++ x) [] ys Is it a problem that I'm using the ++ function? What's a better way to write this?
I implemented and and or: -- or is like and, only it returns True if -- any of the boolean values in a list is True. or' :: [Bool] -> Bool or' [] = False or' (x:xs) = x || or' xs --and takes a list of boolean values and returns True only if -- all the values in the list are True. and' :: [Bool] -> Bool and' [] ...
I would much appreciate your advice on this design I am going to implement. I am relatively new to object programming and I am not so sure about the delegate pattern. I need to provide the implementation of a class that implements several interfaces of different nature. As the class would be huge I am thinking on using...
I'm trying to solve a practice problem and all is well except for the last 2 inputs my solution is too slow. Just one loop is slowing it down I think. Herd Sums Execution Time Limit: 2 seconds Problem Statement The cows if farmer John's herd are numbered and banded with consecutive integers from 1 to N (1 ≤ N ≤ 10,00...
I needed a simple way to trim a string of words based on a max character count. I also needed to cut in-between words. Using WordPress, here is what I came up with, but I feel like it could be more efficient. function count_words($content) { $partsArray = explode(' ', $content); return sizeof($partsArray); } ...
I have wrote simple class that allowing database selection and inserts.Could you please tell me does this a right way to use __call method with any useful advantage of it ? <?php class _getDatabase { public $db; public function __construct(PDO $connection) { $this->db = $connection; } public ...
I have a method in my class that eats up something like 80% of my processor time while its running. In-fact one line within the method is responsible for the majority of this. The idea behind this class is to stabilize the depth readings being returned by the Microsoft Kinect device by obtaining the average value of th...
I'm building a page that downloads a list of Geocaching CWGs for my country in XML, and then parse it. The structure of the XML looks like this: <cwgkatalog> <cwg> <cislo>8245</cislo> <id_katalog>8245</id_katalog> <kategorie>cwg</kategorie> <verze>1</verze> <guid>891a8e4d-9de...
What's the best way to iterate over two collections of equal length? Currently I'm using this: for(var index = 0; index < collection1.Count(); index++) { var item1 = collection1[index]; var item2 = collection2[index]; Console.WriteLine(item1.ToString() + ", "+ item2.ToString()); } But I'd love to be able t...
This is something myself and a former colleague were working on and I've finally finished it but wanting to see if we've done as well as we can or if it can be further optimised. Also looking at doing a new feature for getting a list of all services rather than hosts and find the status of the service on each host. Her...
I have this blade template with a main.scss file: include "layout.blade" replace block page ul.brand(data-orbit data-options="animation:slide;\ pause_on_hover:true;\ animation_speed:500;\ slide_number:false;\ navigation_arrows:false;\ bullets:false;\ swipe:true;...
I'm building my own micro MVC framework with only the absolute core functionality. My router will call the controller depending on the request method (GET or POST), and if the called action isn't supported it will default to the index action. Is my approach correct? Any suggestions for improvement? abstract class Cont...
How can this be optimized? $text = "reverseesrever"; // Reverse and esrever $b = false; for($i = 0; $i < strlen($text); $i++) { if($text[$i] !== $text[strlen($text) - 1 - $i]) { $b = true; break; } } echo ($b) ? "YES" : "NO"; // result: NO.
I'm fairly new to C# and I thought this program was so simple it was a great candidate for a good ol' code review. This program syncs the results of one MSSQL database and puts them into a MySQL database based on the datetime value. I always tend to do things the hard way when I start off on a program and I am always...
I had a problem where I needed to find the largest amount of passengers in multiple cars/vans etc, so I got the totals from each vehicle and added them to a list, I then created this method to sort the list... static List<int> SortList(List<int> tobesorted) { var j = 0; int JP = 0; int value1 = Convert.ToI...
My task is to add the specified element to the linked list if it is not already present /** * Adds the specified element to this set if it is not already present. * @param o element to be added to this set. * @return true if this set did not already contain the specified element. * @throws NullPointerException - if th...
I would like to receive feedback about my code. Is there any better way to shorten the code or is it fine? Demo var pass_strength; function IsEnoughLength(str,length){ if ((str == null) || isNaN(length)) return false; else if (str.length < length) return false; return true; } function HasMi...
The code is part of a very basic 2D platformer based on code from the book Killer Game Programming in Java. The methods are part of a TileMapManager class which is handling basic collision detection. The first method returns the greatest distance that an entity can travel in the y axis (up to deltaY) without colliding...
I have recently taken a small technical test in C# and the following were expected: All stories to be completed with an appropriate level of testing. No actual database implementation is required, feel free to stub it out. Your code should trend towards being SOLID. Make sure you write mock objects and do good unit te...
I'm doing my best to explain how this works, but it's pretty confusing and lengthy. Let me know if there's something I can do to clarify. I'm building a class that models a custom Plist and sets its values to properties in the class automatically. Most importantly however is the core concept of populating the properti...
I've got some constructors and a factory class that I would like to use in an Angular project. I would like to know how I can convert these to usable Angular services for my project. Process Constructor /** * A constructor for Process objects * * @param {Object} options An object with an integer processId and an arr...
I created a method that does division without the / operator. I believe this code is a bit slow and can be improved, but I am not sure how to do so. I'm not so good with shift operators (>> and >>>), but I believe that this will help a bit. How can I change my code to increase the speed of the division. I am open the c...
In my application there is a "config" object that is accessbile by multiple threads concurrently. It is a single object (singleton) injected by the DI in the "dependents". Until now, this (the "config") object was immutable which makes it inherently thread-safe. However, there is a new requirement that the "config" sho...
I wrote this function to do unordered_set intersection using templates. I have seen this answer but I thought that it was overkill. I would like the method to take in 2 sets and return a set. class SetUtilites{ public: template<typename Type> static boost::unordered_set<Type> intersection(const boost::unordered...
I am practicing various tree algorithms and that require code review for it's efficiency, clarity and also if it can be made better etc. Is there a better way to call parent.findMin(parent) TreeNode.java package binarytree; public class TreeNode { TreeNode left; TreeNode right; int data; TreeNode pare...
I wrote this code, based on the Newton-Raphson method, to find the square root of a number. I'm wondering how I can optimise this code, as I am out of ideas. #include <stdio.h> int main(void) { float n, x, i; printf("Enter the number you wish to find the square root of.\n"); printf("\n"); scanf("%...
I assume you've all played Pacman, I mean, most people have. I am a 10th grader, and I am working on building Pacman for my intro to Java class in school. However, the project I'm working on demands that someone review my code. About the code: I have not started the graphics yet. I have just done a little work using...
I want to use the output of the terminal command ldd: root@kali-vm:~/Desktop# ldd simple linux-gate.so.1 => (0xb7722000) libcurl-gnutls.so.4 => /usr/lib/i386-linux-gnu/libcurl-gnutls.so.4 (0xb769c000) libc.so.6 => /lib/i386-linux-gnu/i686/cmov/libc.so.6 (0xb7539000) libidn.so.11 => /usr/lib/i386-linux-...
Consider this naive stack implementation in Elixir: defmodule Stack do defstruct name: "", value: 0 def init() do _s = [] end def push(name, value, s) do s_new = [%Stack{name: name, value: value}, s] {:ok,s_new} end def pop(s) do [h|tail] = s {:ok, h, tail} end def depth(s) do ...
I found a problem here. I am sharing the problem and my attempt at solution. I would like to find out if this is the best approach possible. One day, at the "Russian Code Cup" event it was decided to play football as an out of competition event. All participants was divided into n teams and played several matches,...
I have a jQuery function which adds a tag to the first row of a table. I previously tried using append, however that didn't work. I now have the following solution which is very slow and it gives this warning: A script on this page is causing Internet Explorer to run slowly Function: jQuery.fn.fixGridView = function ...
I've built a base class that I use a lot in my iOS app to make calls to web services. I built the base class to make the actual call and this base class is only ever used by another class. The idea was that should I decide to change from AFNetworking to something else, I would not need to rewrite code in many other cl...
May there be any performance and/or code standard improvements on the following LineOfSight code? static List<Coordinate> getIntersects(Coordinate c1, Coordinate c2) { // Bresenham's line algorithm from http://rosettacode.org/wiki/Bitmap/Bresenham's_line_algorithm#C.2B.2B List<Coordinate> returningVector = ne...
Continuation of this question: Unit of Work with Generic Repository Pattern MVVM, vol. 3 I have made some changes. The methods GetFeedBySomething() have been replaced by Find() GetRepository() has been added to UoW I separated DAL from Model Model inherits IBaseEntity from DAL (not sure is it correct) IRepositoryWithI...
I've been working on improving my website code. I've noticed that querying from a table inside a PHP while function, where while loop is also querying another table: while($row = mysql_fetch_assoc($table1)){ $table2 = mysql_query(select); mysql_fetch_assoc($table2); } It might be slowing down the performance, dependi...
I've been trying to figure out a clean way of managing mappings between two objects. In the case of this example, it's two hashes. This spec should illustrate the problem at hand: describe 'key mapping' do let(:have) { { data1: 'foo', data2: 'bar', data3: 'baz' } } let(:want) { { LINE1: 'foo', LINE2: 'bar', LINE3: ...
Recently I've attended an interview, where I faced the below question: Question: "There is an sorted array. You need to find all the missing numbers. Write the complete code, without using any generics or inbuilt function or binary operators. First and last terms will be given. Array will be sorted. Array always s...
I have made a program in C++ simulating a dictionary with very basic functionality. I do not have much experience in file handling with C++. Also, I want it to run on Linux and Windows. It would be great if you could review/improve it on these things: The file handling part of the code Detecting whether the progra...
Basically I want some help in reducing the bloat of this code. I am new to JavaScript so this represents an attempt at learning jQuery by doing. All of this code works as I want it to, but it is not efficient or maintainable long term. I realize there is no context for what is going on, but I figure that someone could ...
Okay, so I'm a self-taught programmer and have been brushing up on all the 'boring' bits that CS students do that most of us self-taught ignore. Things like Algorithms and Data Structures (particularly). So I found a nice exercise book that explains how algorithms work, but then leaves the implementation to the reader....
We regularly have to convert a bunch of autotask Contracts to a custom CRM entity because we have employees who don't work in Autotask but need those contracts. I wrote the above code to handle this job. this code is supposed to run in a scheduled batch it retrieves all CRM accounts; it loops over all accounts, doing ...
I just created the following code and am wondering whether it is logically correct (all other feedback is of course also welcome): public interface HandView extends View<Hand> { void onCardAdded(final Card card); void onCardPlayed(final int cardIndex); void onCardsSwapped(final int cardIndexOne, final int...
JSFiddle: http://jsfiddle.net/yMSHa/ (Note: Real code uses JQuery 1.4.1) HTML: <div data-name="action" data-id="1">Do It A 1</div> <div data-name="action" data-id="2">Do It A 2</div> <div data-name="action" data-id="3">Do It A 3</div> <div data-name="action" data-id="4">Do It A 4</div> <div data-name="action" data-id="...
I've got a LoggingMessageHandler that incoming requests on my WebApi application filter through. public class LoggingMessageHandler : DelegatingHandler { public ILogManager LogManager { get; set; } //injected protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, System.Thread...
I am new to Scala and I have written a function which uses pattern matching to filter words based on some conditions. It seems to work correctly but I am suspect that I haven't used the Scala pattern matching in the best way. I think this because each of my cases contain an if statement. I have not seen any examples...
I've written a recursive method for fetching grid neighbours in a symmetrical 2-dimensional grid, the problem is that I've found myself duplicating the code more or less into an overload to prevent my list from re-initializing everytime the method calls on itself. I'm guessing there are ways to get around this that doe...
So my problem is this, I need to create a grid that in each cell there should be a 0 or a 1. These cells when clicked should toggle between 0 and 1. When hovered It should show the coordinates (ex: 1,5). Now the only way I got this to work was by creating three divs. One for the cell (which contains the number), one fo...
I'm serializing instances of a lot of classes (in C# 3.0), and I've found myself writing this: [DataContract] public class ModelClass { public static Guid GetID(ModelClass instance) { ... } public static T FromID<T>(Guid value) where T : ModelClass { } [DataMember] public Guid m_id { get; set; } } [DataC...
Here is my entry for the Code Jam problem Full Binary Tree (I didn't compete but tackled the problem afterwards). It does solve the provided inputs, so I suppose it is correct. I am looking for any suggestions regarding the code. One thing I don't like is the fact that the Node constructor clears the array that it rece...
Because the TPL backport not only contains Parallel.* but also PLINQ, concurrent collections, etc, I will try to use this one. Just for fun, I profiled both the TPL implementation and my own, in the very basic and naive test, mine was actually a little bit faster. Microsoft TPL backport: 00:00:17.0673098 My Implementat...
This seems like an awful lot of code and I'm guessing can be condensed and made more efficient somehow. Can anyone suggest this to me at all? // Add the active class to the first element $('.indexWorkDetailsInner:first').addClass('active'); // Next Button Click $('.indexWorkRight').click(function() { // Move all ...
I have a database that, among other things, stores publications and publication tags. There is a many-to-many relationship between publications and publication tags. Simply put, I query the database for all the publication tags and the corresponding id. While looping through that query, I have a nested query to coun...
This PHP script will translate shots on 18 holes to a total under par or E which is 0. $course = array(0, 4, 5, 4, 3, 5, 3, 4, 4, 4, 4, 4, 4, 4, 3, 5, 3, 4, 5); if ($totalpar == 0) { $score = 'E'; $played = 0; } else { if(!empty($h1)) { $h1score = $course[1] - $h1; } else { $h1score = 0; } if (!empty($h2))...
Background I've just started using VIM and have become comfortable with navigation. I'm attempting to reduce repetitive tasks and thought I would take a crack at mapping. I was able to accomplish my task below with a map command, but would like to know what the best way is to do what I am doing. Task I frequently write...
This has been asked a few times here, but I was wondering what I could do to improve the efficiency and readability of my code. My programming skill has gotten rusty, so I would like to elicit all constructive criticism that can make me write code better. init: #include <iostream> using namespace std; merge() //The m...
I am trying to teach myself OOP in Python. I am picking up some projects from GitHub and trying it out on my own. I wrote a Airline/Hotel Reservation System, where I want to maintain the customer name, ID and maintain a record for Airline or Hotel or Both. I am not sure if my design is correct. I want some input on how...
Let me start by saying that I am very happy with this code. I want to share it with other people because I think they will find it helpful, but I want to make sure I did everything in good form before I do so. The code allows users to easily manage their image memory. The class handles all of your images, which means...
I made a navigation bar on the left side of my site. It works perfectly, the only problem is I'm new to jQuery and I think I'm repeating too much code. Is this the case? If it is please help me out. HTML <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional....
I was doing writing some various things in JavaScript and ending up writing 2 scripts that proved useful in quite a lot of my other programs and I was wondering if there was anything that I could do better because I'm fairly new to JavaScript and jQuery after a fairly long history of Java/C++. Both programs have __ pas...
As I am relativistically new to programming and lack any sort of formal experience in the matter, I was wondering if any of you with a bit more knowledge in the subject would be willing to tell me if the following code is an acceptable way to accomplish a function binding event handler in Java 8. I admit that the namin...
This program calculates the square root of an unsigned 32-bit number with some bit fiddling to get a very close approximation, then one iteration of the Babylonian method to get an exact value. I don't know if this could be faster, but hope it can. I have trouble with clearly commenting my code, so I will gladly explai...
My concern with this code is the excessive use of .encode('utf-8'). Any advice on refining these functions would be very helpful. rss2html GitHub repo #!/usr/bin/env python """ Simple rss to html converter """ __version__ = "0.0.1" __author__ = "Ricky L Wilson" from feedparser import parse as parsefeed import Strin...
This question originates from this post. Anyway, I'm trying to solve the following problem: Given a 3x3 grid with numbers 1-9, for example: 2 8 3 1 4 5 7 9 6 I have to sort the grid by rotating a 2x2 subgrid clockwise or counter-clockwise. The above example could be solved like this: Rotate the top left piece clockwis...
Also posted at rgcsm.info/blog //Number Guessing Game in Java Swing //Also posted at import javax.swing.*; import java.awt.*; import java.awt.event.*; class Guess extends JFrame { JTextField t1, t2, t3, t4; JLabel j4; ButtonListener bl1; ButtonListener2 bl2; ButtonListener3 bl3; //sett...
I have the following method for multiplying two polynomials in GF(232): #include <iostream> #include <cassert> #include <ctime> #include <random> #include <wmmintrin.h> typedef unsigned short uint16_t; typedef unsigned int uint32_t; unsigned get_high16(unsigned x) { return (x >> 16) & 0xffff; } unsigned get_low1...
I am currently developing a game for Android. One of the things I am working on is moving the map by touch. This is the code that handles getting speed, which is then added to the screens position and the next update draws the corresponding portion of the map. @Override public boolean onTouchEvent(MotionEvent event) { ...
I have to say without sounding arrogant, because I am only a novice coder, yet after looking at other's solutions, my solution is definitely not the shortest and most lightweight one and probably not even close to one of the most optimized ones. But! I think I have made a very readable solution and I think that it is t...
Usually when I make mock-up programs (like this one), I look for things I can improve on in case the situation happens again. Today I thought I'd brush up on basic OOP (I understand the concept of OOP, just haven't messed around with it for a bit and wanted to freshen my memory). So I decided to make a little game tha...
I decided to roll out my own EventBus system which is intended to be thread-safe. Hence a review should focus extra on thread safety apart from all regular concerns. The EventBus can work in two ways: You can register events and listeners directly on the EventBus. You can the methods, of a specific object, that are si...
I am writing a Python script that scrapes data from Google search results and stores it in a database. I couldn't find any Google API for this, so I am just sending a HTTP GET request on Google's main site (and also Google News site). Then, using Beautiful Soup, I extract the number of search results found. I store thi...
I had time measuring pretty much figured out when I ended up using this structure. #include <iostream> #include <chrono> template<typename TimeT = std::chrono::milliseconds> struct measure { template<typename F> static typename TimeT::rep execution(F const &func) { auto start = std::chrono::system_...
I wrote my first simple image upload script that allows users to add items to a database along with pictures of said item. My script takes the images uploaded via a form, processes and resizes them and finally saves them to a hard disk, with their file paths added to a database. While my code is currently working, I ha...
This is a class to hold an animation and be able to refer to different animations by titles, but it seems like calling draw(Graphics2D g) and update every frame, would, with this implementation, cause a big slowdown with all the list.get(Object obj) calls. Is this a big deal, and if so how should I change the implement...
I am still learning the javascript language. Recently I've written simple code for a task list. I am searching for improvements and advice from more experienced users. Are there any improvements, changes or specific patterns for this task? PS- I wanted to use pure JavaScript (e.g. no jQuery or AngularJS) as this is on...
Here's how I wrote the Haskell splitAt function: splitAt' :: Int -> [a] -> ([a], [a]) splitAt' n ys | n < 0 = ([], ys) | otherwise = splitAt'' n ys [] where splitAt'' a (x:xs) acc | a == 0 = (acc, x:xs) | null xs = (acc ++ [x], []) | otherwise...
I am writing a fully functional single player Connect 4 game. I am working on the second player and the while loop that tells the player who won. GUI package lab7; import java.awt.GridLayout; import java.util.ArrayList; import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JFrame; import jav...
I am running my shell script on machineA which copies the files from machineB and machineC to machineA. If the file is not there in machineB, then it should be there in machineC for sure. So I will try to copy from machineB first, if it is not there in machineB then I will go to machineC to copy the same files. In mac...
I wrote this code, but it feels like it could be a bit more elegant: Relevant code only: GameObject newBall; GameObject pathBall; if (tag.Equals(pathBallTagName)) { newBall = other.gameObject; pathBall = gameObject; } else { newBall = gameObject; pathBall = other.gameObject; } Entire .cs file: using Un...