instruction stringlengths 71 39k |
|---|
I've built a simple dice class utility for rolling dice. It supports weighted rolling, and usage is fairly simple. Here's the code.
from random import choice
class Die(object):
"""
The Die class represents a sided die
with n amount of sides. Sides can be
weighted. For example:
die = Die({
... |
First, the script checks to see if it is installing two kernel module packages or removing them by looking at the first parameter. If no parameter is provided it complains and exits.
If installing, it checks if each of the packages even needs to be installed by looking at the version of the existing module. If they do ... |
I have written Minesweeper in JavaScript. Using OO-Approach.
Cell class describes a cell in the grid.
Cell.t property tells whether the cell is a mine or not.
Cell.count property stores the number of mines in the cell's vicinity.
Cell.state property stores whether the cell is used / unused / flagged.
Grid class provid... |
This code was for a university assignment. It's well passed now so don't be scared of giving me false grades, for example. I was wondering what could be done better, or bits of code that are horribly inefficient or are bad practices.
def main():
import time
while True:
try:
num1 = int(input... |
I made a website last night that allows people to sync HTML5 <video>s (playing/pausing). The way it does this is by using Ajax to run a MySQL query every 2 seconds to check if anyone has paused the video. Depending on the response, it plays/pauses it. If someone plays/pauses the video, it calls a page through Ajax to u... |
The code below was refactored for performance improvements for another user on this site.
Functionality, high level:
Sheet1 - CodeName aIndex: used as the main reference to the structure of the data being processed in 2 other sheets: mapping column headers for incoming data in sheet2, to column headers to be processed... |
I have the following in script in my web app which contains a lot of duplication. How can I cut down on this duplication and generally improve my code?
$('a#newAuthority').on("click", function() {
var $newAuthorityContainer = $(".new-authority-container");
var $row = $('<div />', {
class: 'row'
})... |
Project Euler Problem 61 asks:
Triangle, square, pentagonal, hexagonal, heptagonal, and octagonal numbers are all figurate (polygonal) numbers and are generated by the following formulae:
$$\begin{array}{lll}
\textrm{Triangle} & P_{3,n}=n(n+1)/2 & 1, 3, 6, 10, 15, \ldots\\
\textrm{Square} & P_{4,n}=n^2 & 1, 4, 9,... |
Would really appreciate it if someone could please review my String Calculator TDD KATA.
String Calculator
Create a simple String calculator with a method int Add(string numbers). The method can take 0, 1 or 2 numbers, and will return their sum (for an empty string it will return 0). For example "" or "1" or "1,2".
S... |
This should be really simple. I'm searching for the cleanest & shortest way to add a newline to a non-null String if it is not empty, i.e. myString.isEmpty() is true. I know of a number of ways to do this, but none of them are as elegant as I would like them to.
For context, the string I'm working on will essentially b... |
String Calculator
Create a simple String calculator with a method int Add(string numbers).
The method can take 0, 1 or 2 numbers, and will return their sum (for an empty string it will return 0).
For example "" or "1" or "1,2".
Start with the simplest test case of an empty string and move to 1 and two numbers
Reme... |
Imagine that you have a TreeSet of numbers, and you copy them into an array, but you remove one element of it. You want to know the element removed.
import java.util.Arrays;
import java.util.Set;
import com.google.common.collect.Sets;
public class Question {
private static final Set<Integer> SET = Sets.newTreeSe... |
I've written a directive to validate the width and height of an image in AngularJS. I'm not a JS genius but I get along with it. So I would appreciate some feedback on this directives code if this can be done better in the context of Angular and the JS language itself.
angular.module('app').directive('imageFileValidato... |
I'm trying to figure out how to correctly hover over an image to fade in another image and when you move your mouse out, it would go fade back to the normal image.
$(document).ready(function(){
$('img').hover(
function(){
$(this).stop().fadeOut(function(){
var $temp = $(this).attr('src');
... |
This is the first time I am working on OOJS code and I am a beginner in JS. I think I have pretty much messed it up. I am planning to modularize my code, but with the inclusion of rest calls, I got confused and have messed up my structure. The trouble I am facing is that my success function of Ajax call keeps growing w... |
I have an entity named Program. Program can have a collection of Agreements. I want to add agreement one by one.
The following method takes a programId and an Agreement itself. And then first find the program by id. If program is found, it then finds the agreement from the database. If agreement is found in the databas... |
I want to get the query result that contains all entries from array and some data from the DB.
It's like the array is a DB table and by left join I connect the data that I need.
I've solved this task in a clumsy way and am asking for tips on how to rewrite this solution.
Here is my query:
$subquery = 'Select \'... |
I am new in JS, I am writing some extra filters on the Interface. So extra filter needs to add or update the parameter in the URL.
Option 1. No parameter in existing URL:
url = https://custom.net/
We want to add new parameter in the URL where key issector and value is IndependentConsultingDoctors
Output will be: https:... |
I'm emulating a little bit the .on() from jQuery in an old Mootools version. One of the project requirements is that Mootools can't (shouldn't) be upgraded (using version 1.2.x).
Basically I'm checking the element itself and its two closest ancestors (like .parents() in jQuery).
My working code is:
Element.implement({
... |
I am in the midst of writing a simple job board and I have the URL's filtering and working how I want, everything works - I just want to know if I can improve it, if there are any security concerns, and if it is horribly inefficient.
Take the following URL section - foo.com/in/london/at/google/do/design
I assign each s... |
I've created a small, strongly-typed generic Service Locator object for .NET 3.5.
It supports optional polymorphic service location and keyed services. I am looking for a general review, but especially looking for pointers on best practices I've missed or any awkwardness in the API.
This code can also be found as a pub... |
I am to implement a parallel version of FastICA, so I implemented the serial version of FastICA.
Now this is the architectural diagram of how it is going to parallelize. I just coded a basic thread model of this. But I need to know what I did was correct or wrong regarding inter threads synchronization.
#include <co... |
This is the current iteration of my first model of a Person. The model is populated by a survey application using forms.ModelForm and a SessionWizardView which splits the survey over multiple pages
Would anybody be able to tell me if I am making any obvious mistakes? Any advice or efficiencies are much appreciated. I a... |
I am working with the output from a chemistry instrument, in .xls format.
The output contains up to seven blocks of data corresponding to different types of samples e.g. controls, unknowns, calibrators, etc... Each block is 15 columns by a variable number of rows, ranging from 3 to 15. The first row contains headers, t... |
I have working code here which takes two lists and turns them into a dictionary with the first list being the keys and the second being the values. If the keys exceed the values the value "None" will be assigned to that key.
def createDict(keys, values):
i = 0
dictionary = {}
# go through all the values in... |
I have started my clicker game using angular.js about week ago. I have finished current functionality first night, but still have feeling of misunderstanding some basic approaches.
This is sources root on github. I'm trying to follow angular-code-style.
First of all, I'd like to hear some thoughts about code structure.... |
Go is a board game (it looks like 5-in-a-row and plays like chess) and I tried to program it in Java.
Rules:
Two players take turn placing stones on a board. The goal is to capture teritory. Stones can be captured (removed from game) if they have no unoccupied adjacent tiles horizontaly/verticaly. Adjacent stones (ho... |
I'm trying to clone a Dots game with some little differences (power ups and objectives) as a school project. I have almost every objective done so now, I'm not trying to get my work done for free. I am however asking for code structure advice and to learn if you find any horrible mistake. I'm sorry that the code isn't ... |
I'm working on an API testing algorithm within the Postman REST client and I wanted a simple and elegant deep diff function to test my JSON responses. I only have access to Lodash within Postman's testing sandbox.
I couldn't find one on SO or elsewhere online so I decided to write one for myself. My goal was to write t... |
I'm new to Slim and the three layered approach I'm using below. So far I have the API, a Presentation layer (leaving out for now), a Business Logic Layer, and a Data Access Layer. The code's working, but I know it can be improved a lot. I'd really appreciate some feedback from you all.
A few things I'm questioning alre... |
I just coded a version of WaTor, a population simulation game in which fish and sharks move around, breed, and eat each other. I am wondering how I did and if there are better ways to do some of the things I am doing, specifically on the move methods for the sharks and the fish.
Animal
package WaTor;
abstract class An... |
I have this PHP function that adds custom user profile fields to WordPress. It saves the field through the WooCommerce form-edit-my-account.php file. I have a lot of repeated code, and would like to clean it up.
function save_sfirst_account_details( $user_ID ){
$sfirst = ! empty( $_POST['sfirst'] ) ? wc_clean( $_PO... |
This code does the following:
Read CSV file and determine sub_type based on series_desc.
Turn row into dictionaries new_person and new_subscriptions.
Check list people for the new_person and add the person if it is actually new.
Check each person in the list people for the new_subscription and add it if it is not ther... |
I used jQuery-UI and jQuery to create a dialog popup for help snippets on search form inputs.
HTML (Calling Page)
<a id="Help" href="#">
<img alt="help Symbol" src="Icons/helps.gif" style="border-style:none;"/>
<span>Name Search</span>
</a>
<div id="dialog-confirm" title="Name Search Help" style="display: none;... |
I created a Pandas dataframe from a MongoDB query.
c = db.runs.find().limit(limit)
df = pd.DataFrame(list(c))
Right now one column of the dataframe corresponds to a document nested within the original MongoDB document, now typed as a dictionary. The dictionary is in the run_info column.
I would like to extract some o... |
I have an array of objects that have a key attribute with the name of a country and a values attribute that is an array of values that contain data by year:
I needed the opposite: an array of objects where the key is the year and the values an array containing data for each country in the original array.
I wrote this... |
I have created an open source memory cache called cachew and can be found here:
cachew. I would like your help to make it better.
Regarding the class Cache or its dependencies:
I am thinking of removing timeoutStyle and timeout from the Cache constructor and providing default values that can be changed via public prop... |
I made a simple Blackjack game in Python 3.4.3. I'm a beginner, so it would be awesome if you could rip up my code and tell me everything I did wrong. I know there's no insurance for when the dealer has an ace (yet), and there's some other blackjack rules that I'm going to add in the future, but I wanted to get a base ... |
I wanted to share my code for others to critique. This program is something I started while struggling with homework problems in my Statistics course, and after getting the ball rolling, I decided to keep adding and perfecting it. Right now it is in a usable state, but I want to hear the opinion of other more experienc... |
I needed to implement a data structure that supports the following operations:
create from an existing collection
get the maximum item ("Alpha")
get the nearest-to-maximum item ("Beta")
get the minimum item ("Omega")
get the sum of all items ("Sum")
reduce the maximum item to a lower value
perform an arbitrary operati... |
Problem Statement:
Given a word and a text, return the count of the occurences of
anagrams of the word in the text. For eg. word is “for” and the text
is “forxxorfxdofr”, anagrams of “for” will be “ofr”, “orf”,”fro”, etc.
So the answer would be 3 for this particular example.
The above is an interview question ... |
I'm writing adapters for some MS Access database because I really didn't like that automatically generated code that Visual Studio was providing. Right now I just need to get data, not updating anything over there, but that will come later.
Here's some code that I'm using (all the adapters look the same, so that is wha... |
I coded a math quiz in PHP in which a user selects radio buttons as their answer choices. I retrieve the data of these ten radio buttons using $_POST[]; However, I have ten separate post queries for EACH radio button as well as SQL queries, and also ten separate if statements to check for each correct answer. It looks ... |
This is a userscript that simply adds the number of pages that a thread has next to its title for Flickr interface. (FWIW it's not really done because the script is only loaded at page load, but not reloaded on subsequent AJAX calls that the user may make).
I'm far from being a seasoned JS developer, so I'm looking for... |
I've created an SDL input manager for my 3D OpenGL applications. It's not finished yet, but I would like to know if I'm doing it the right way.
I really tried to optimise and compact my code, as it is for an OpenGL library.
InputHandler.h
#pragma once
#include <SDL2/SDL.h>
#include <vector>
#include <glm/glm.hpp>
#incl... |
I have two lists of objects Person and PersonResult. Both are linked through the property PersonId. I need to create a filter for the list of PersonResult that meet certain criteria for the Person (e.g. Person.Gender == "female").
Im currently using the following LINQ query to achieve this:
PersonResultList = PersonRes... |
I've written a small program that draws a vector field in R using ggplot for a given differential equation.
There is a topic on the subject here however, the proposed solutions either don't provide the same functionality as the code below or don't use ggplot.
//example differential equation: f_prime = f(x,y)
f_prime ... |
Sometimes when working with components created by a library vendor such as DevExpress you want to extend the components. Good vendors will leave plenty of virtual methods for you to put to use, but once in a while you need to hook into an interface method call in a class that implements the method explicitly. You can s... |
I've been writing a program to synchronize two or more folders. I've read that methods should be kept short. While most of mine are, one method is ~50 lines:
public void ModSync(List<mySyncFol> dirf, string logpath)
{ // Sync Everything to most recent modified
int a = 0, ac, b=-1, li = 0; // a =... |
As writing code to handle error-checked input or to present functions to execute to the user is boring and error-prone, I wrote a module to automate these tasks:
user_interface.py
def general_input(prompt="", type_=str, min_=None, max_=None,
max_length=None, set_=None, cap_sensitive=True,
... |
I'm having trouble finding a clean way to handle checked exceptions thrown by a lambda function passed as a parameter in Java.
I'm writing a Client which will interact via RMI with a Server to play a game; a Client needs to be registered on the Server to be able to login, and it needs to be logged in to play a game. It... |
I'm using a transaction statement in SQL Server 2012 for the first time.
I want to insert Table1's data in Table1_Backup before I delete everything from Table1. Same process for Table2. Should I name my transactions? Does this transaction code even look right?
DECLARE @err int
BEGIN TRANSACTION Table1
insert into [Ta... |
We have the following equation (weighted phase Laplacian):
\$c_{i,j} = U(i,j)\Delta^{^x}_{i,j} - U(i-l, j)\Delta^{x}_{i-1,j} + V(i,j)\Delta^{y}_{i,j} - V(i,j-1)\Delta^{y}_{i,j-1}\$
Where
\$U(i,j) = min(w^2_{i+1}, w^2_{i+1})V(i,j) = min(w^2_{j+1}, w^2_{j+1})\$
with \$U, V, \Delta \$ (N,N) matrices
I coded the following ... |
In an effort to understand how compilers work, I wrote a simple expression calculator in C#. A CalculatorExpression takes an infix string, converts the infix string to postfix, and finally takes the postfix to an internal BinaryExpression tree representation.
To use, simply create an expression, and then evaluate:
va... |
This post is complementary to this one
I asked the question about implementing DropBox's "Share link" functionality on the server side in the most "secure" way. Of course, real security involves at least password-based authentication, not this "security by obscurity" approach, but the guys from DropBox managed to imple... |
I was thinking about using very basic bounded (preallocated) stack to keep track of my threads IDs in correct LIFO order. I was wondering if my implementation is thread safe:
// we use maximum 8 workers
size_t idle_ids_stack[8];
// position current write happening at
std::atomic_uint_fast8_t idle_pos(0);
// this funct... |
I'm practicing by writing utilities for myself; I prefer CSS3 transitions over jQuery animations whenever possible. This is intended to be used for transitioning multiple DOM elements who's relationship to one and other is only given by the context (ie. on clicking a menu icon, hide/show, relocate, resize, etc. multipl... |
I want to create a web app that should let users remotely make a device do a variety of things simply using any other device, anywhere, without installing anything. To do that, the device which performs tasks should receive commands as fast as possible, and, possibly, using few Internet data.
This is the code I'm going... |
There was some online test where I was asked about finding all possible distinct palindromes of a string.
Here I had to give the count of all possible distinct palindromes of a given string (continuous substring). Here, a single character word is considered a palindrome.
Below is what I did. Can you please tell me if i... |
I have been working on a script that automatically checks on the state of 2 services that I require to be running 24/7 on a server that I manage.
The script works as I need, but I would really like to optimize it if possible.
Specifically, I find that I want a way to reduce the need to type the command:
$(ps -ef | grep... |
I am working on an ad form for a local newspaper. I am not familiar with the programming side of things, still learning. I was able to successfully get the form to count the words, but I need it to quote the price based on different packages/ word counts. Here is an example of the form and what the price structure e... |
I'm a beginning Python programmer, and earlier I made a simple Blackjack game in Python. The original version (which can be found here) got a lot of great feedback, so I rewrote the entire program to reflect the feedback I received. Again, any tips are appreciated.
import random
import itertools
# generates the deck a... |
Warning: I'm quite new to low-level programming and memory management so please don't mind it when I'm asking incredibly stupid things.
I'm working on a project where I need to read all the lines from a file and store them for further usage. I decided to use a linked list of untyped pointers for this which will contain... |
I wrote a method which computes the ratio of even to odd numbers in an array. I know it's a simple piece of code, but I wanted to see if you have any feedback for improving it.
public double percentEven(int[] a) {
if(a.length <= 1) {
return 0.0;
}
double even = 0.0;
for(int i = 0; i < a.length; i++) {
if(a[i] %... |
I need to refactor this class having in mind that the logic inside the call methods is not so short and it require spring dependencies to work, the base class I have is:
@Service
public class ConcurrentService{
@Autowired
private Service1 service1;
@Autowired
private Service2 service2;
public exe... |
I am creating a simple 2D canvas game engine in JavaScript. Are there any optimizations that I could make, or obvious issues (performance, semantics or otherwise) that you can see?
JS Bin here
var GameCanvas = {
// GameCanvas Variables
animation: {
requestAnimationFrame: null,
halt: false
},... |
This code addresses performance issues specific to Android running Xamarin / C# when downloading images (BMP/PNG) into a listview. The caller simply specifies the URL to fetch the image from, and the preferred dimensions.
Optimisations I could do, but haven't:
Not sure if I should use the Android or Java namespace
Sta... |
This code is for a NodeJS logging module. I created it because I wanted to find a way to log different type of things but not show them all at the same time. I also wanted to format the logs in a custom manner.
Is there anything I could do to improve this code, such as making it shorter? Are there still any bugs?
// or... |
My buddy schedules a dart tournament, and got into trouble when there were some scheduling conflicts. He has the first 3 weeks in the books, and needs to finish out the rest of the schedule. Turns out it is a pretty difficult puzzle.
So I figured I could quickly solve it with a constraint satisfaction problem. Unfortun... |
I am a beginner to Java and have just written a number guessing game which involves guessing numbers from 1 to 10. I would like to improve my code by sticking strictly to conventions, improving code efficiency and forming good coding habits from the beginning.
Main class:
public class Main {
public static void mai... |
I recently made the switch from procedural to OOP style of coding. I decided I wanted to learn how everything works before deciding to jump into a framework, follow tutorials, and becoming dependent on the tutorials/help from others. This is my take on dependency injection so far, I didn't see the appeal in a page that... |
class text_generator
{
public int getWordIndex(List<string> source, Random value)
{
return value.Next(0, source.Count - 1);
}
public bool checkListLength(List<string> source)
{
return source.Count == 0;
}
public string getText(List<string> source, List<string> backup_source, R... |
This program first displays a menu which shows some options that the user can select. Each option will the respective functions which do some things.
The user can insert a filename, read data from it, enter a regex pattern, test if each line of the file matches the given regex pattern.
Please provide feedback on how I ... |
I've got a list with tuples of variable length containing nodes, out of which I want to build a network:
node_list = [("one", "two"), ("eins", "zwei", "drei"),
("un", "deux", "trois", "quattre"), ("two", "zwei", "deux")]
Each tuple represents a subgroup in the network. I want to add each node with edges t... |
I have the following code:
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <cassert>
#include <vector>
#include <cstdlib>
#define BOOST_FILESYSTEM_NO_DEPRECATED
#include <boost/filesystem.hpp>
using namespace std;
using namespace boost::filesystem;
static ofstream Log; // For info... |
I have this project in data analysis for creating a ranking of tennis players. Currently, it takes more than 6 days to run on my computer.
Can you review the code and see where's the problem?
Project steps:
I have a database of 600,000 tennis matches called matchdatabase.The database fileds are a) winner name, b) lose... |
Here is a classical attempt to implement a lock-free stack (based on this article). I rewrote it in C++11 and also tried to add memory orders which I would like to confirm to be correct.
template<typename T>
class stack
{
struct node_t final
{
T value;
node_t *next;
};
struct head_t f... |
I have a search on a very simple spring-powered website and I want to display 10 recent inputs:
import java.util.Collection;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Exec... |
My code takes a starting position (which must be completed) and a list of updates (each element of which is optional). It then projects future positions, using the appropriate value from each update, if present, or using a formula otherwise.
I'm looking for ways to reduce code duplication, especially as the real data s... |
I've refactored my previous question finder, and added multi-tag support, and support for searching for keywords in the question titles. Essentially, what it does is find questions that could be answered based on the following parameters.
-- @MinimumQuestionVotes - The minimum amount of votes on a question.
-- @Maximum... |
So, we have this "Rubberduck Settings" window, with a number of "tabs" dedicated to each configurable feature. The "root" tab contains the application's "general settings" and, in the next release, we've found something to put there:
The display language! Credits to @SimonAndréForsberg and @Vogel612, for the Swedish a... |
I designed a framework to make the switch from procedural to OOP design. This question will contain multiple parts I will bold each question to make reading/dissecting easier. I attempted to look into these questions through Stack Overflow, Google, PHPReddit, etc. and I ran into a variety of answers, most of them bashe... |
I wrote a procedure to calculate the number of months elapsed since a sales agent' last sale. It works but runs in over 10 minutes... for 20 rows.
Sub Latency()
' this sub-routine is used to calculate the no of recent idle months by an agent
Application.ScreenUpdating = False
For Each rng In Range("BL1:BL13000")
j = 1
... |
In a table there is a number of column (chambre) and a number of row (alveole). If these matches in a list in an other sheet then it checks if it the date is between two dates on that second sheets. If it matches those 3 things, then it puts the sheet
My code works if I add DoEvents in every For, else Excel and VBA sto... |
Note: see the next iteration.
I have this tiny library for (de)serializing lists of objects. The requirement is that each object's state may be represented textually as a single line of text. Later on, the deserialization routine attempts to map each text line to the object it encodes.
Factory.java:
package net.codero... |
I am embarking on the daunting journey of learning to program on my own two feet and have created a turn-based battle simulator (think Pokémon). The idea came from here.
It's very crude and could probably use a lot of refinement, so I'm willing to listen to any criticism and advice on improvements.
# Turn Based Bat... |
I wanted to make a Stream that can wrap another stream and buffer all writes, to increase performance; comparable to the BufferedStream class.
However, while BufferedStream is strictly synchronous, and will block once its inner buffer is full, until the contents have been written to the underlying stream, this stream ... |
This is my first Java program to print out the Armstrong numbers.
An Armstrong number is a number that is the sum of its own digits each raised to the power of the number of digits.
I want to get better, so be harsh and straightforward.
public class Armstrong {
public static void main (String arg[]){
in... |
I am currently working on a re-occurring broadcast schedule. The whole idea is to setup a cron/task job that will update the broadcast flag "isLive" in a database table. Are there other options to optimize the PHP code below?
Live Table (livevent)
+----------+------------------+------------+--------+-----------+-------... |
I created this small script to strip the data out of tables that have hyperlinks as their <th /> elements. I was hoping to get input on code clarity and possibly simplification, efficiency is not much of an issue for me as there are not any huge tables on Wikipedia.
var arr = $('tbody').children('tr').map(function(idx)... |
I am developing a web crawler application. When I run the program for more than 3 hours, the program runs out of memory. I should run the program for more that 2-3 days non-stop to get the results I need. How is this program using memory inefficiently?
seeds.txt
http://www.stanford.edu
http://www.archive.org
WebCra... |
My code seems a bit sloppy to me, but I don't know how to improve it to make it cleaner and more understandable. I'm just learning Python, as well as Tkinter. I figured a Pythagorean Theorem calculator should be a simple enough jumping-off point. The code works however, I don't have any tests in place so, at the moment... |
I'm a freshwoman at Systems Information, new to Java and programming and was assigned this task by my professor.
My job is to read characters from a text file (file details in the bottom), recognizing each char as an integer. I should extend a class that will make bitwise operations to each char as to change them. For ... |
I am learning Scala still and refactoring some old code. I was hoping the community here could give me pointers to fix this code up since there are some issues I have with it visually, but don't know if there's an elegant solution for my vision.
class PhoneNumber(phonenumber:String) {
def number: String = {
phon... |
#include <iostream>
#include <memory>
using std::cout;
using std::endl;
template<typename T, int dimension = 1>
class Array
{
private:
std::unique_ptr<T[]> pointer;
int size[dimension];
int realSize;
public:
Array()
{
}
template<typename... Ns>
Array(Ns... ns)
: realSize(1)
{
... |
ALL I want to do is making binary search tree, inputting there from users, and then print out data in each node one by one according to the user's selection (whether he choose to print the data in the right node of the current node or the left). So I only define three functions: prompt(), inputData() and printOneNode()... |
I wrote a couple of basic Clojure functions (practicing a declarative style) and I was looking to get some feedback on them. You can see all the code here. Is there anything I could improve on to write more functional style code? How could I improve my tests? (Code can be run with lein test if you have Leiningen instal... |
I'm currently trying to brush up on my assembly skills and, being at the FPU section of the tutorial, I implemented a very basic version of a Monte-Carlo-Algorithm to compute pi. I deliberately use the x87 instruction set instead of SSE because that's what I'm learning at the moment. What would be the pros and cons of ... |
I had faced a interview question to find the gdc(greatest common divisor) for an integer array of element in optimised way :
Sample case :
a[] = { 10,20,19,15,13}
Result = 1
sample case :
a[]={9,21,12,15,27}
Result : 3
I have submitted following result during the interview. But he asked to optimise the same. S... |
This is a improved version of the program seen in my older question.
This program first displays a menu which shows some options that the user can select. Each option will the respective functions which do some things.
The user can insert a filename, read data from it, enter a regex pattern, test if each line of the f... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.