instruction
stringlengths
71
71.9k
I recently joined this GitHub project based on a user script that offers a powerful editing tool to Stack Exchange Editors. My Goal: In the past few days, I've spent many hours improving the code, but today I re-wrote the whole thing into a completely new infrastructure. Here was my objective as written in a discussi...
I want to add a parent reference to a tree like structure. The structure can be seen in the first code snippet, which also is how I would use my code, for example inside an angular controller. $scope.tree = Tree.parentize({ title: 'root', children: [{ title: 'child one', children: [{ ...
In the spirit of Google's angular.js Style Guide, I set out to define my angularjs controllers as classes, complete with instance functions. I ran into trouble, however, when trying to access injectable services (like $resource) from inside one of those instance functions. I wanted a way to avoid having to write functi...
This below code implements a simulation of an ocean(as 2d-array of cells) which currently have Shark, fish or be Empty. User can run this simulation, as shown below: > java Simtext 25 30 1 With this command, SimText will animate a 25x30 ocean array with a starveTime of 1 unit. /* point.java */ package Project1; /** ...
How better to refactor nested if-blocks? error_reporting(E_ALL); ini_set('display_errors', 1); // Usage: emailhandler.php?from=<sender>&body=<body>[&to=<device>] // CREATE TABLE inbox(sender VARCHAR(255), rcpt VARCHAR(255), body VARCHAR(255)); require_once '../incl/Config.php'; require_once...
I want to have a class that stores data from an input file, for use in a simulation program. It is like a struct but may require some small functions for accessors. A seperate class reads all the data from a text input file. I want to store most of this data in the above mentioned object. Therefore this class needs to ...
It took me while to finish, but here is my custom matrix class. I assume that the row/column iterators are the most critical part of this class but anyway I would very much appreciate your ideas of this project. #include <iostream> #include <iomanip> #include <ios> #include <sstream> #include <algorithm> #include <fu...
I wrote a bash script for reviewing scientific articles. It adds a blank page for notes and creates a new landscape file. I'm sure it can be made better code wise. Any suggestions? #!/bin/bash if [ $# -ne 1 ] then echo "Usage example: ./bashscript src.pdf" exit $E_BADARGS else NUM=$(pdftk $1 dump_data | grep 'Nu...
For our (internal) automated test project, I am writing a part where parameters can be passed to an SSIS Package before it gets executed. The tester delivers the parameter name, value and desired datatype in a table format. I get the datatype and parses it to the correct type. We assume a happy flow (when testers do so...
I wrote my first ruby script, by this tutorial. It creates a local and remote git repo. I have been working for about 3 years with PHP, and somehow I find that my ruby script looks incredibly ugly. Is it correct to use a class for that? What can I make better? Are there any security gaps in it? Is the usage in for ...
The following script uses a switch statement to determine the numeric month based on the actual month. Is there a more succinct way (read: elegant, or less time to write) to accomplish the same result? Is there a down-side or up-side to either approach? jsFiddle var month = "May"; var m; switch...
I have to calculate the premium from a rate chart based on a person's age and the amount of insurance they request. I started out using if/switch statements, but the code is getting too long and seems pretty redundant. var premium; var beneAmt = $('#PrimaryApplicantTTLBenefitAmountInput').val(); var age = $('#PrimaryAp...
I have the following code that I need help with refactoring: Validation class for objects you may create: Email address URL Norwegian Mobile Number (must start with 4, 9 or 59 and be 8 digits long) <?php /** Validation Class * Class to to validate any Data send by user depend in Data type and Rules ...
I have the following js code: if (typeof errorCallback === "function") { var result = errorCallback.apply(this, arguments); // if errorCallback returns a non-false value, end execution if (result) { return result; } } // if there's no errorCallback or errorCallback returned 'false', // 'null', ...
I am making a sentiment analysis library targeted first at social media text (like Twitter) and then I will expand it for more general use. For the first step I am making a simple interface and a class that is going to be used for storing some data about the text to be analyzed like the text itself, it's manually annot...
I am currently writing my bachelor's thesis about on-line handwriting recognition. This is not OCR, because I have the information how a symbol is written as a list of pen trajectory coordinates (x, y). I call this hwrt - handwriting recognition toolkit. It has a documentation and a friend of mine got the "first steps"...
Please comment on this. class MinHeap<T> where T: IComparable { List<T> elements; public MinHeap() { elements = new List<T>(); } public void Add(T item) { elements.Add(item); Heapify(); } public void Delete(T item...
My code works fine. I just want to have your insight and opinions about the way I did it. For example, is it easy to maintain? Does it have good architecture and design? <html> <head> <title>Quizz</title> <script src="http://code.jquery.com/jquery-1.11.0.min.js"></script> <script> var quiz = [{ "question"...
I'm reviewing some code and I came across this: // Select the last parameter in the list if (parametersListBox.SelectedIndex > -1) { parametersListBox.SetSelected(parametersListBox.SelectedIndex, true); } ParametersListBox being a C# ListBox. Despite the fact that the comment is wrong, does this actually do someth...
I have created a set of functions, that when given a struct of structs full of names, it will highlight those names that appear in a body of HTML based text. Is this the best method of doing this? <cfcomponent> <cffunction name="init" access="public" output="false" returntype="PartnerHighlighter" hint="Pseudo-constr...
I want to learn best practices for structuring these kinds of small jQuery plugin libraries. I believe I am using a bad design pattern and what I was going for is fewest line numbers and minimal code. Please advise on any better practices and any ways I can reduce the code down further. (function() { var animationS...
File descriptors are a common resource in Unix and Unix-like operating systems. They're a way to represent a resource such as a file, socket and so on. The user should release a file descriptor as soon as (s)he's done with the corresponding resource: tipically they're limited to 1024 per process. I implemented a RAII...
I'm working on a simple micro-benchmarking library in Java. This library makes it easy to benchmark multiple reference implementations. You provide the inputs and trigger the calls, the library takes care of executing N times, measuring the runs and printing the averaged results. Essentially, it works like this: Creat...
This is for a class assignment. The objective is to write a program that will take in user input for employee information and print the wage based on hours worked. Please review my code. #include <ctime> #include <iostream> using namespace std; int GetSalary(int,int,int,int); int GetYearsOfService(int); int main()...
During my hiatus, I decided to revisit some of the Tic-Tac-Toe questions here. I created a simple Tic-Tac-Toe GUI game, and then thought, might as well do the Ultimate Tic-Tac-Toe challenge. I am looking for ways to refactor my code. Particularly in MainWindow.cpp. I think this is a mess. I spent very little time on ...
I've created factory to create WPF controls. I have string with control name and I map it to enum. I think it's bad implementation of factory pattern. So please show me where I've made mistake. Main interface public interface IWpfControl { string Name { get; set; } double ActualHeight { get; } double Actual...
I can't seem to find a very simple light weight image gallery, so I decided to build my own. I'm not an expert in jQuery/JavaScript, so I was hoping some suggestions could be made to make this production material. I have a working example on jsfiddle. data-rel will end up being the full size image URL while img src wi...
A batch file executes WinSCP.exe's console mode to download files and log the actions. Upon exit, WinSCP returns: ERRORLEVEL 0 if the files are successfully retrieved or ERRORLEVEL 1 if there is a problem with the connection - time outs, etc. - or if no file is found Unexplainably, WinSCP will occasionally return 0 wh...
For this project: NetBeansProjects/EntAppWeb/ ├── build.xml ├── EntAppWeb-ejb │   ├── build.xml │   ├── nbproject │   │   ├── ant-deploy.xml │   │   ├── build-impl.xml │   │   ├── genfiles.properties │   │   ├── private │   │   │   ├── private.properties │   │   │   └── private.xml │   │   ├── project.properties │   │...
I need to execute the same set of statements but with a different name of the field each time. I was wondering if there is a better way to write this? int returnCode = collectValue("empName", record); if(returnCode <0) { return false; } returnCode = collectValue("empNum", record); if(returnCode < 0) { return false; } ...
I have the following code in my class and its init() method. It works fine as it is but I'm wondering if there's a better way to do this so that my init() and initialisations aren't so cluttered. Should I have separate initialisation methods for each component that my init() can call? I'm mostly trying to just learn go...
I have written an implementation of Quicksort in Python. I am new to Python. Any suggestions for improvement or criticism on my use of Python? def partition(a, lo, hi): i, j, v = lo+1, hi, a[lo] while(True): while(a[i] < v): i += 1 if (i == hi): break while(a[j] > v):...
I have written an implementation of a Mergesort in Python3. An Ideone with the implementation is available. Any suggestions for improvement or any criticisms? def merge(a, aux, lo, mid, hi): assert isSorted(a, lo, mid) assert isSorted(a, mid+1, hi) for k in range(lo, hi+1): aux[k] = a[k] i, j ...
Working on this homework from 2013 for self-learning. For the following Algebraic Data Type: data JoinList m a = Empty | Single m a | Append m (JoinList m a) (JoinList m a) deriving (Eq, Show) I implemented tag: tag :: Monoid m => JoinList m a -> m tag Empty = me...
I'm fairly new to Java, arriving in the "future" from C and returning to type safety from Python. I've programmed an algorithm to return the weight of the heaviest path from the root of a binary tree to one of its leaves. Each Node in the tree has a weight (its data). The weight of the path is the sum of all of the N...
I have Client and Server classes. The Server return a ResultWithNestedTask instance. public class ResultWithNestedTask { public Task<String> NestedTask; public string Result; } The Client displays the data from Result, then waits for the completion of NestedTask and displays the result from NestedTask. The Se...
I'm attempting to backup lots of website using this php code. The script basically goes through the whole public_html directory and adds all the folders and files recursively and zips them. Here's what I've got so far: if (!file_exists('/home/sites/'.$_SERVER['SERVER_NAME'].'/cbitsbackup/')) { mkdir('/home/sites/'.$_SE...
Project Euler Problem 2 asks for the sum of all even Fibonacci numbers below 4 million. My first attempt at this problem using functional programming with F#. I would've liked to use some kind of take-while function to keep generating Fibonacci numbers until they fulfilled certain conditions, but alas I could not find ...
In an effort to brush up my algorithms and data structure skills I have a done a queue implementation without using built in data structures, i.e. using only arrays. Any comments on this code regarding issues, bad/ good practices and good style would be greatly appreciated. #include <stdexcept> #include <cassert> #incl...
I needed to make a small script to read a csv file and store 2 columns in Redis. Can you guys take a look over the code and let me know how I can improve my code style? #!/usr/bin/env/ python """Proces csv file and store key-value pair of columns in redis""" import csv, redis, json from sys import argv, exit REDIS_HO...
This is my first Python project. Let me know how I did, and where I can improve it. # Random Lottery Number Pick Tool # It has U.S. national lottos and two from Nebraska # I'll add more to it later. import random # here is a giant body function I wonder if I could make this easier to deal with? # it is basically my p...
Target I wrote this program in a few free hours when I was on an excursion as "youth leader". I had created a game to explore the house, with a 40-field mechanic, using dice for advancing and question-based setbacks. The dice and questions were managed outside the program. De-facto this was just to show progressions o...
I'm trying to make sorting of objects in my program as fast as possible. I know that sorting with a cmp function is deprecated in python 3.x and that using keys is faster, but I'm not sure how to get the same functionality without using a cmp function. Here's the definition of the class: class Topic: def __init__(s...
I am trying to find an algorithm to find all the defined neighbors of a 2D Point (efficiently would be nice, but does not make much of a difference). Here is my existing code: private static ArrayList<Point> getNeighborsOfPoint(int i, int j) { ArrayList<Point> neighbors = new ArrayList<Point>(); if (CON...
This is a program you can compile on Windows. The program is an invitation of a chat system for programmers. Once you press enter, you will open the link with your default Internet browser. You can learn more from the program itself. 102 lines of code 4 377 bytes size of source file 192 984 bytes size of binary execut...
I'm passing the data to PHP server side which will use the information later as this: <script> function encrypt() { var salt = CryptoJS.lib.WordArray.random(128/8); var key256Bits500Iterations = CryptoJS.PBKDF2("'.$token.'", salt, { keySize: 256/32, iterations: 500 }); var iv = CryptoJS.en...
I started creating a small abstract simulation framework and would be happy if someone could take a look at the code and give me feedback on it. The code can be found here, and it is currently not in a 100% finished and tested state. It should be (almost) multi threading ready. This is some sample code on how you can u...
Perfect forwarding is usually done with std::forward. E.g., template<typename T> void foo( T&& t ) { bar(std::forward<T>(t)); } for some function bar(). Sometimes, only a member of t, say t.x, needs to be forwarded. This is also a solved problem template<typename T> void foo( T&& t ) { bar(std::forward<T>(t).x...
After reading a lot about interfaces, which I'm new to, I've tried implementing it in my inventory system for a game I'm working on. I have managed to create something proof of concept which seems to work as intended, but I wanted to check with more experienced C# programmers if this is the correct/best approach? The p...
I am trying to come up with a better solution to the following problem: Statement You are supposed to write a function which takes the contents of a document in string format and also a whole number, n, providing how many results to return. (So that's two arguments for the function.) The function should return the n ...
I'm looking a way to make my k nearest neighbors search more efficient. The context of the question is that I'm given a list of topics that have a unique ID (integer) and a (x,y) coordinate (floats) associated with each topic. Subsequently, I'm given another point and the number of nearest topics to find around the giv...
This is my finished function to find the length of the longest consecutive subsequence of an input array of integers. It's for an assessment so things like the numerical method used and the format of input are out of my hands (int LIS(int* seq, int* temp_seq, int seq_size)). For the temp_seq parameter, the caller will...
I am trying to implements a map (that can work as a cache) that has strings as keys and values of different types. In my real case once set the key/values in the map will not change. I used these classes, I take as example the Item 29 on Effective Java 2nd edition. This is the class for values: final class CachedValue ...
I use the following script to autotag the current workspace while building even if there are changed (not committed) files: #!/bin/bash tagname="autobuild-test1" commitname="autocommit for tag $tagname" set -e head="`git rev-parse HEAD`" test -n "$head" git commit -m "$commitname" -a taghead="`git rev-parse HEAD`" gi...
This is a speed distance and time calculator - the comments should explain most of the odd looking code if there is any. I am looking for suggestions to improve the efficiency of the program and how better to structure it - is my approach the best from a 'best practices', efficiency and OOP point of view. So, specifica...
I am testing various sorting algorithms. Right now I am testing shell sort, insertion sort and selection sort. I ran all three algorithms on a randomly-generated list of 1000 integers. The selection sort took 41 seconds, insertion sort took 34 seconds and shell sort sort took over 3 minutes. What can I do to improve my...
Project Euler Problem 45 Triangle, pentagonal, and hexagonal numbers are generated by the following formulae: Triangle Tn=n(n+1)/2 1, 3, 6, 10, 15, ... Pentagonal Pn=n(3n−1)/2 1, 5, 12, 22, 35, ... Hexagonal Hn=n(2n−1) 1, 6, 15, 28, 45, ... It can be verified that T285 = P165 = H143 =...
The idea being you can have a simple type called maybe that wraps another type, which provides the ability to possibly not return a value from a function. I'm sure it's not perfect yet, but it's got the broad strokes I'm looking for. I'm mostly looking for corner cases I've missed and anything else I've overlooked. #...
It only does expressions with 2 operands yet, but I'm wondering if there are any ways I can improve this: # infix.rb: parse infix-operated math expressions class String def is_number? true if Float(self) rescue false end end class InfixParser @operations = [ '/', '*', '+', '-' ] testString = '(24 + 6) / ...
I have recently started learning Python and one of the assignments I have been working on is a Caesar decipher. Can you tell me how I can make my code better? def caesar(code, shift): ''' (str, int) -> str Shift every letter in the code by the integer 'shift'. >>> caesar('ABC', 2) CDE >>> caesar('a b c', 4) ...
I created this code to make a basic calculator after viewing a few examples. I added the function to continue the calculations myself. I am wondering if there is a way to make this more efficient as I feel I've used some unnecessary code but I can't make it work without. I also was looking for feedback on my codes read...
Is this a good design? I would like to create a view on user table to get a list of users based on filtered conditions. Please suggest ways of improving this schema design. A view example that I would like to add on this schema: Select all users who belong to group and all groups created after that group. Select all u...
Related to this question, I wrote the (+++) function to join 2 JoinList's: (+++) :: Monoid m => JoinList m a -> JoinList m a -> JoinList m a (+++) Empty y = y (+++) x Empty = x (+++) left@(Single _ _) right@(Single _ _) = Append (tag $ Append mempty ...
For the Join List algebraic data type: data JoinList m a = Empty | Single m a | Append m (JoinList m a) (JoinList m a) deriving (Eq, Show) This homework's problem states to implement indexJ: Exercise 2 The first annotation to try out is one for fast indexing into a JoinList ....
I am computing factorials as part of teaching myself C++. I am looking for feedback on efficiency, style and any bad practices I may be using. #include <iostream> #include <climits> using namespace std; int main() { unsigned int number{ 0 }; unsigned long long factorial{ 0 }; cout << "The factorial of a n...
I don't use C# very often so would be good to get some feedback on this helper class using SharpDX.DirectInput; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace SprintTimer { class JoystickHelper { priv...
I require feedback on the plethora of bad practices that are definitely existing in the following code: #include<fstream.h> #include<conio.h> #include<stdio.h> #include<process.h> #include<string.h> #include<iomanip.h> //*************************************************************** // CLASSES USED ...
I have solved one programming problem where we have to find all the permutations of given numbers. For example, \$[1,2,3]\$ have the following permutations: $$[1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], [3,2,1]$$ I have written the code for it and my code successfully cleared all the tests. But, I am not really sure a...
My code does the job for the most part, but I don't think the two functions that look for the highest and lowest score are the best approach. The instructions tell me to use the int as the return instead of double, but I can't tell how to take this approach. A particular talent competition has 5 judges, each of whom a...
Usually, C++ standard library algorithms have two versions, e.g.: template< class RandomIt > void sort( RandomIt first, RandomIt last ); template< class RandomIt, class Compare > void sort( RandomIt first, RandomIt last, Compare comp ); Where one version is default in some sense and the second one is customized. When...
Please let me know if you think I can improve the structure of his table code. <table> <tbody> <tr> <th rowspan="2">Date</th> <th rowspan="2">Tournament</th> <th colspan="8">Tournament Scores</th> <th colspan="2">Result</th> <th rowspan="2">Score <br>Card </th> ...
I am trying to write a script to securely delete a file. What I am intending to do is to pad the file with /dev/zero once, and then with /dev/urandom three times and then delete the file. For now the user only accepts one file at a time and the functionality is limited, if I am on the right track then I'll add more opt...
Can the below code be improved? Are there any major issues with it? Thanks Writer w = client.sendMessageData(); for (File file : myAttachments) { w.append("\r\n").append("--").append(bound).append("\r\n"); w.append("Content-Type: application/octet-stream\r\n"); w.append("Content-Transfer-Encoding: base64\r\...
I needed to add existing models to a has-many relation using nested attributes so I overwrote thumbnails_attributes=: class Gallery < ActiveRecord::Base has_many :thumbnails, dependent: :nullify accepts_nested_attributes_for :thumbnails def thumbnails_attributes=(thumbnails_attributes) ids = thumbnails_attr...
This program counts the total number of times any character from the source string can be found in the target string. E.g Source String - "Hello World" Target String - "llo" Output = 5 (as there are 3 l's and 2 o's) Source String - "Hello World" Target String - "ooood" Output = 3 (as there are 2 o's and 1 d) Is there a...
I have seen UInts being natively supported in other languages. PHP allows you to install a third party extension, but I can't do that ATM, so I've decided to create my own class. In which ways could/should I improve my code. Both in terms of overall code quality aswel as performance? final class UintArray implements \C...
I'm writing a simple front controller, index.php is the main file. In my index.php, first thing loaded is bootstrap.php via require_once(). I'm deliberating over two ways to load bootstrap.php: A) require_once 'bootstrap.php'; B) if ( is_readable('bootstrap.php') ) { require_once 'bootstrap.php'; } else ...
I am going through one of my class library projects, and while nothing is wrong with it, I am finding myself being a bit anal, and wanting to organize things a bit differently. The project in particular that I am looking at reorganizing, is a class library to hook into a multitude of databases, and do work on them. No...
I wanted to know if this is the best approach for the Single Responsibility Principle. The responsibility of this class is to remind users whose accounts are about to expire due to inactivity. On the 30th day of inactivity, the user gets an email. On the 45th day of inactivity, the user does not get an email; they get...
I have created the classic "guess the random number" game: Generator Interface package ishan.guessingGame.randomNumberGenerators; public interface RandomNumber { public int generate(); } Generator Implementation package ishan.guessingGame.randomNumberGenerators; import java.util.Random; public class SimpleRando...
This is a really simple chat room that I've made using Firebase. Before I take it to the next level I want to know if there is anything I can improve right now. Since I'm new to Firebase I don't know a whole lot about it so any pointers are greatly appreciated. var myDataRef = new Firebase('https://insertnamehere.fireb...
Edit: I am hoping to get some review / make sure I am understanding dynamic programming correctly. I am trying to print out all additive numbers up to digits n using dynamic programming. Additive numbers are those like 123, 1235, etc., where the sum of every 2 digits from left to right is equal to the third digit. In...
The previous failed attempt This question derives from this other question I made. In the previous question I tried to use a Monte Carlo algorithm; sadly it did not work. I am doing an hardcoded AI I therefore decided to try an hardcoded AI, but not for 21 game because it would have been too trivial, for a more general...
I wrote a small reusable component based of some of the examples to this question on Stack Overflow about Activating OnBeforeUnload only when field values have changed. It works like this: You can specify the portion of the page that it will use to listen for any data changes to input fields by adding the class .alert...
I have been reading a bit about statistics to improve the way I understand data. This is my attempt at calculating Standard Variance using data tables. I solved this simple question: This is the code I used (I used SEDE to execute it): CREATE TABLE #Numbers ( Number DECIMAL(10,4), Variance DECIMAL(10,4) ); GO IN...
I was profiling my code and annoyed by the continuous calls of Profile.run(my_function()) Profile.run(my_next_function()) so I decided to make a context manager instead. This seems pretty straightforward but I wanted to make sure nothing about it was bad - I was a little surprised that you couldn't use it as a contex...
I am to implement a stack in C using a linked list. My code is below. My design: I use stack_ prefix to each function, and each function has a Stack* self pointer. This is similar to object-oriented languages’ bundling of data and methods. I do not know how idiomatic this is in C. Each function returns a bool indicati...
I made an immutable list class using the head-tail idiom. If I did this correctly, it implements persistent data structures. Unfortunately it doesn't scale well as VBA is not tail recursive. Note: I use a method called seq.Assign to handle assigning objects without using Set. I would like to copy the objects and pr...
Can you improve my state engine which consists of the state engine based on an interface and an example menustate? It all works fine but seems a bit cumbersome in terms of the way I have to change states and also report on what state the engine is in. Can this be coded more elegantly? public class StateEngine { //P...
I got my navigation bar to be the color I want of Blue background with white text. Here is my code which works but this feels totally hacky. Please suggest improvements styles.xml <resources> <style name="AppTheme" parent="@android:style/Theme.Holo.Light"> <item name="android:actionBarStyle">@style/MyActio...
I am trying to write a program which, given a number as an input, prints the prime factors AND the exponents of the prime factors of that number. Example: Input: 20 Output: 2^2 5^1 And this is the code that I've come up with: #include <cstdio> #include <vector> #include <map> #include <algorithm> std::vector<int>fac...
This is a LeetCode problem called Word Ladder: Given two words (start and end), and a dictionary, find the length of shortest transformation sequence from start to end, where only one letter can be changed at a time. Each intermediate word must exist in the dictionary For example, Given: start = "hit" end = "co...
Long story short, I wrote this jQuery form plugin as an exercise to better understand how other form plugins work. If you have any suggestions about how to improve this (or my coding style in general) let me know. var Form = function(options) { options = options || {}; this.url = options.url; this.$fields...
I have a header and data which I need to represent in one Byte Array. And I have a particular format for packing the header in a Byte Array and also a different format to pack the data in a Byte Array. After I have these two, I need to make one final Byte Array out of it. // below is my header offsets layout // m_off_...
In modern C++, there is no class like datetime in the standard which can be used in the program. However, with additional of modules like <regex> and <chrono>, we can write the general purpose class like datetime. Here is my current implementation for this: #include<iostream> #include<string> #include<chrono> #include<...
I am working on a parenthesis checker program in Java that reads in a text stream from standard input and uses a stack to determine whether or not its parentheses are properly balanced. For example, this should print true for [()]{}{[()()]()} and false for [(]). I have made a stack class of my own: public class Stack {...
For this lab you should re-use your Dice class from the previous week. The user inputs a number n which determines the number of groups of 6 dice to be rolled. The program should output x, which is the number of times 6n dice are rolled before they show an equal number of all values. For example, if n is 1, then ...
Which form of the method do you find more readable? Version with local variables: public void checkRetrievedIds( List<Integer> expectedIds, List<Integer> retrievedIds ) { Set<Integer> expected = new HashSet<>( expectedIds ); Set<Integer> retrieved = new HashSet<>( retrievedIds ); Set<Integer> difference =...
This is called from a VF page, styleClass="{!IF(isWindows8Device, 'windows', 'not_windows')}" So if it's a windows device, return true. The best thing to do would be to add one method in DeviceDetectionCls to check for any windows device, instead of two methods. For the purpose of this question though, I've to use b...
Problem Statement: Design a STUDENT class to store roll, name, course, admission date and marks in 5 subjects taken from user. Create an array of STUDENT objects. Provide methods corresponding to admission date and receiving marks, preparing mark sheet. Support must be there to show the number of students wh...