instruction stringlengths 71 71.9k |
|---|
My task was to perform a basic string compression by replacing consecutive repeated characters by one instance of the character and integer denoting the number of repetitions.
For example the string "aaaaabbcccdeee" should be reduced to "a5b2c3de3".
I have tried working in C# using a simple logic. Please see the below... |
"""
### General Idea:
Given a set of n character set C.
1. Begin with a set of |C| leaves.
2. Repeatedly using **min-priority** queue `Q`, keyed on frequencies,
identify the two least-frequent objects to merge together.
3. Until all be merged.
### Input
List of tuple containing frequency and character.
### Outp... |
I've been working my way through Pedro Domingos' machine learning course videos (although the course is not currently active). His first homework assignment starts with coding up a decision tree (ID3). The decision tree is used in subsequent assignments (where bagging and boosting methods are to be applied over it).
My... |
I need to merge eve/odd rows on a data set.
Example:
match team count points
1 1 ARG 11 21
2 1 ENG 9 19
3 2 CAN 8 15
4 2 USA 8 17
5 3 FRA 7 7
6 3 NZL 8 36
To:
match team1 t1p t1s team2 t2p t2s
1 1 ... |
I have many object of class Test. I want to be sure that among them, there are no two objects o1 and o2 where o1==o2. In order to achieve that, I want to add them all to a HashSet and check if hashSet.size() == numberOfInitialObjects .
In order to ensure that the potential future changes in equals method of the Test ... |
I am working on a sample REST service to study testing related aspects using the Python Bottle framework. I read a lot about REST but I do not have a lot of practical experience designing RESTful APIs (e.g. this https://www.ics.uci.edu/~fielding/pubs/dissertation/fielding_dissertation.pdf). I am using Bottle the first ... |
I have an algorithm that takes in an array of interections found between lines in an image. It then has to look for any instances where there are a group of intersections together, remove the middle ones and give me back all the edges of it.
I have it working as well as I need it too except for the performance... it t... |
I have created a Utils class, which consists of progressDialog and AlertDialog:
public class Utils {
public static ProgressDialog dialog;
private static AlertDialog.Builder builder;
private static AlertDialog alert;
public static void showLoader(Activity activity) {
if (dialog == null) {
... |
I build my first "bigger" program with classes. Does this look good? Or do you see something, which I could do better?
Do you think I could use a delegate for changing the stones to money here? And how to do this?
using System;
// collect stones
// if 20 stones collected --> event --> change stones for money
namespac... |
I am writing a small chunk of code (a module>?) that I will use to create a view on a page using angular. The angular directive will take care of generating the html.
The sole purpose of this module is expose a given month's data, specifically on what day it starts for the given year and how many days it has. I want to... |
New to Neural Networks and before I move on to gradient descent I would like to make sure I have got basic idea right. (Sorry that the class is called perceptron I know that this isnt technically right, I adapted this code from
and AND gate NN). This NN is made to learn the XOR function.
#include <iostream>
#include <... |
The program here is simply supposed to tell you the shipping charge based off of the weight of the package. I am just wondering if there is any further way to concise it? At the moment, I do not think it can go any further than that. The only place where I'm unsure whether I could improve it, could be Booleans. Possibl... |
I developed this class to download a JSON from a server, parse the result and call a delegate back on the class that called it. Since I am self started I want to know if this is a good practise.
DataController.h
#import <Foundation/Foundation.h>
#import "Reachability.h"
#import "Movie.h"
//This class is a data control... |
I created a little Kotlin clone of the 2048 game that is playable in the console. My goals were readability and statelessness for no other reason than practice. Consider it a code kata wherein I didn't want to mutate the original grid, instead returning a new permutation for every operation.
To this end, I would greatl... |
I decided to throw this together today figuring it would be cool to add to my repertoire. Before we always had performed this "task" externally. Find the value we want to compare, hash it and compare with a valid hash. But my idea was to bundle this into a object which behaves nicely with string types. It then could in... |
I have an API which I want to consume in Python 3.x using the requests module.
Right now, my solution is to create Requests objects for each URL like the LoginRequest, etc. (see below).
I have one request per API URL and need to write the __init__ method for each class depending on the parameters that are requested for... |
I have done this small piece of code used to search for a given word across several fields of a Django model.
Goal was to have first entries equals to the word, then entries starting by the world and finally just entries containing it.
I would like to have feedback on it :
# -*- coding: utf-8 -*-
"""Module created to ... |
As the name suggests it is a very simple program to print numbers to screen till user inputs 42.
(map
println
(take-while
#(not= % "42")
(repeatedly #(.readLine *in*))))
I have started learning Clojure so please share whether there is some easier way to read lines or anything else that can be improved.... |
I've implemented my own version of the Control.ControlCollection class in System.Windows.Forms and obviously I want it reviewed.
I've tried to make it thread-safe all around, but I'm sure I missed something.
My main concern is obviously the thread-safety of it, but I also would like any other comments as well.
The GitH... |
I had a hardware project for a 5x5x5 RGB cube which is driven by a 22118400Hz 8-bit AVR (1284p for those who like hardware).
Basically, the class sets the bits in a huge array of 8-bit values (exactly 5x30x10 uint8_ts).
To understand why a short excursion:
The array contains 5 for the level, 30 for the color multiplex... |
Below I have some code that I use to handle incoming socket data, this is not full thing but its the part I am worried about, is there any way to improve this?
int packetPosition = 0;
while (packetPosition < packetData.Length)
{
try
{
... |
I have a solution here, but I'm not too fond of it because I feel like it can be done better.
template <typename Comparable>
bool AugmentedBinarySearchTree<Comparable>::Rank(const Comparable& x, BinaryNode* t, int* nodesVisited) const {
if (t == NULL) {
return false;
}
if (Rank(x, t->m_left, nodesVisited)) {
... |
I've made my attempt to code timer entirely by hand using jQuery. No external libraries to manage time at all.
$(document).ready(function() {
var setSessionMinutes = 5,
setBreakMinutes = 5,
sessionMinutes = setSessionMinutes,
breakMinutes = setBreakMinutes,
counterSeconds = -1,
countTimeout,
runState = f... |
I came across this problem in a career cup. Below I have the questions and the Java solution. I was wondering if anyone could scrutinize my code and tell me if there are any improvements, or better coding practices that I should know, as I am working on being able to produce proficient code.
Problem statement:
Write a... |
I need to parse an excel sheet in order to produce an statistic, and some of the columns in the sheet can have different value types within the same column. For example:
A B
String String
String String
Date String
I cannot force the columns to have a consistent type because the input sheet belongs to one o... |
I'm very new to programming in C and I attempted to make a program that converts temperatures to and from Fahrenheit and Celsius. I have been running the program and I have realized that not all conversions are correct. For example, if I use the boiling point of water (100C or 212F), I get an incorrect answer. I though... |
I recently have been working on a BinaryTree class, and looked into creating a proper __repr__ which when eval'ed would recreate the exact binary tree as the original.
The following code for __repr__ works as expected, but I'm wondering if there is a better way to handle the removal of values which already has a defaul... |
Here is my method that I use to get one entity in an ASP.NET Web API application.
[EnableQuery]
public virtual HttpResponseMessage GetById([FromODataUri]int id)
{
// get concrete entity from repository
var entity = repository.GetById(id);
// check entity
if (entity == null)
{
var message = st... |
I'm trying to get all files paths and names to index them in my database for faster search in future. I have used multithreading and parallel classes, but I'm couldn't get the performance I expected. There is an app named "Search Everything," which indexes all my files in less than 2 minutes, but my code takes much lon... |
Could you please have a look at my programming style? Is it ok? Do I create any redundancies in code which I haven't noticed?
import java.util.Scanner;
public class TicTacToe {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int[][] board = {
{0, 0, ... |
I am writing Python code which reads through two text files and prints the output based on those two files. Basically, the first file, demo.txt, has a matrix of numbers and the second file, days.txt, has a value. Based on that value, many digits in the first file are replaced with the $, ?, or just a space.
Anyways, my... |
I need my string-to-int converter to handle all exceptions without throwing any errors. I also have a use case where I need the default value to be less than zero if the TryParse is false.
Is there a built-in way of doing this?
Should I make any changes to the method?
public int ToInt32OrDefault(string value, int d... |
This is my ProcessDataFileParallel.Java file. I'm taking numbers from a .txt file and putting it into an array in Java. While it works, I would like to improve the code and possibly change some algorithms to better alternatives.
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
impor... |
My thoughts are to create a method that contains all of the variables declared. Is it better to say initialized?
I would like it to be more efficient but still as clear as possible for future maintenance of the code. Any suggestions for the main bulk of information, such as methods?
if (incomeDec <= 300)
{
taxRate... |
I made some PHP files for the login/registration part of my Android application and I would like to know if it can be made safer.
config.php:
<?php
define('hostname', 'localhost');
define('username', 'alexiz');
define('password', '12qwas!@QWAS');
define('db_name', 'shhaapp_db');
?>
connection.php:
<?... |
I recently learned about using fixed point arithmetic on embedded systems without floating point hardware, so I decided to code it. I tried to write in good style, but emphasized speed over style.
One hard problem I encountered was to convert the number to a string. I coded up the following in my internal class; the ma... |
I want to find the maximum product that can be obtained from any 3 integers in an integer array. The optimal solution has time complexity of \$O(n)\$ and space complexity of \$O(1)\$. I managed to write up as solution in Java that only traverses the array twice (so my time complexity is \$O(n)\$) and my space complexit... |
This is one of my first attempts in writing a bowling scorecard app. It can have more than one player. I would like to know if anyone has suggestions to improve the code. I am trying to make it as object oriented and as organized as possible. There are 2 public methods, one that accepts pins that were knocked down, and... |
So I have been told that my code is not good and needs refactoring. I'm struggling to see what I need to do. How do I specify the success and failure conditions for lambda? Also don't get what the method process_lines should contain. Any help is greatly appreciated!
These are the comments I was given:
Let's create a f... |
I want an opinion of the community about readability and maintainability of the following code.
This is quite a rare case when yield statement included in a using construction.
I know that this code will work as intended and dispose will be called eventually.
But I'm worried it might be difficult for other developers t... |
Given a binary tree, I need to check if it satisfies the binary search tree property i.e. left child is less than or equal to the current node and right child is greater than or equal to the current node.
from collections import namedtuple
Node = namedtuple('Node', 'key, left, right')
def is_bst(node, key_min=None, k... |
The explanation
I'm making a website for a hypothetical theatre to get a better feel of MVC web-applications in ASP.net. The idea is that there are newsmessages that are displayed on the homepage, and these messages can be edited and added via an adminpanel. This is how it looks:
The page works according to the foll... |
Problem Statement: We have \$N\$ sticks. The size of the \$i\$th stick is \$A_i\$. We want to know the number of different types of triangles created with each side from a single different stick. Calculate the number of acute triangles, right triangles and obtuse triangles.
Input Format: The first line contains \$N\$. ... |
I've got strings coming from irregularly and ugly formatted HTML sites, that contain a timestamp. I am interested in removing the timestamp entirely and get all the rest.
from bs4 import BeautifulSoup
date1 = '<P><SPAN STYLE="font-family: Univers" STYLE="font-size: 11pt"><STRONG></STRONG></SPAN><SPAN STYLE="font-famil... |
A number chain is created by continuously adding the square of the
digits in a number to form a new number until it has been seen before.
For example,
44 → 32 → 13 → 10 → 1 → 1
85 → 89 → 145 → 42 → 20 → 4 → 16 → 37 → 58 → 89
Therefore any chain that arrives at 1 or 89 will become stuck in an
endless loop. What i... |
I'm supposed to make a program that will tell me the number of the day of a certain date. So I input the date, and it will tell me which number day it is. (i.e: 1.1.2014 would be day 1, and 30.4.2012 would be 121) The program in its current state works, but it looks a little sloppy (or I'm just too self-conscious). I'm... |
Many people seed their Mersenne Twister engines like this:
std::mt19937 rng(std::random_device{}());
However, this only provides a single unsigned int, i.e. 32 bits on most systems, of seed randomness, which seems quite tiny when compared to the 19937 bit state space we want to seed. Indeed, if I find out the first nu... |
My code finds the value that corresponds to two values in a table. It works fine, but I'd like to know what you might do differently.
Table sample:
Input:
=findval(3200,100)
Output:
4,6
Code:
Function findval(x As String, y As String)
Dim LastRow As Long
Dim LastCol As Integer
Dim x_rgn As Range
Dim y_rgn As Range
... |
I'm exploring ruby by writing a code that checks the sum of all prime numbers under two million. As I am still in the process of learning ruby, I'm unfamiliar with all the standards and best practices. What I have so far works, but I am certain it can be improved. Where can I improve my code for both readability and sp... |
I've made a small function to output a multiplication grid (those things from primary school! :P) to an inputted number.
def make_grid(max):
max += 1 # so the for loops go up to the desired number, inclusive
print('X\t' + '\t'.join([str(_) for _ in range(max)]) + '\n') # print all the numbers hoizontally
... |
I attempted this problem from the ieeextreme, and I got timeout for just over 40% of the cases. Now that the competition is over, I was wondering what could be improved.
The problem is as follows:
Given a grid of size R, C
1 <= r <= 12, 1 <= c <= 10^6
Apply one of 3 commands 'a', 'r', or 'q'
'a', x1, y1, x2, y2: add o... |
I have developed this function but I'm not sure if this is the best (secure) way to write in resources without corrupt *.exe in case of fails.
What is the best way to write resources to a *.exe file?
procedure SaveToRes(const aResFileName, aResName: string; aMemoryStream : TMemoryStream);
var
myRes: THandle;
aUpd... |
I'm currently studying data structures, I have implemented simple single linked list as shown below.
I would like to know how can I improve it?
#include <iostream>
#include <memory>
#include <cassert>
template <typename T>
class List
{
struct node
{
T value;
std::unique_ptr<node> next;
}... |
Write the implementation for generating pattern part, and did some testing, seems good to me. But not sure if any functional bugs? If anyone find a functional bug, appreciate for the insights.
def findPattern(pattern):
j = -1
next = [-1] * len(pattern)
i = 0 # next[0] is always -1, by KMP definition
w... |
I've been working on a code that reads in all the sheets of an Excel workbook, where the first two columns in each sheet are "Date" and "Time", and the next two columns are either "Level" and "Temperature, or "LEVEL" and "TEMPERATURE". The code works, but I am working on improving my coding clarity and efficiency, so a... |
I have one PHP file named database.php:
try {
$connection= new PDO(DB_DNS, DB_USER, DB_PASS);
$connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch(Exception $e) {
echo "Error: ".$e->getMessage();
die();
}
and I have a user.php with class Users:
require_once(__DIR__."/../in... |
I want to convert my list of optional strings to a list of strings by getting rid of the empty Optionals.
Is there a shorter version for achieving this than the following code (except statically importing the methods of Collectors)?
List<Optional<String>> stringsMaybe = Arrays.asList(Optional.of("Hi"),
... |
I want to just write a simple function to check if my linux box has hyperthreading enabled. I want to know if there's a simpler way to produce the cpuinfo dict (would be great if I could use a dict comprehension somehow) or generally a better way to check this information:
def is_hyperthreading_enabled():
cpuinfo =... |
This system allows the user to define property mappings between two objects and a filter. Then the user may call Filters.Apply<T>() to get an IQueryable<T>.
Example Setup
// Called from some program entry point.
Filters.Configure()
.Map<TileVM, Tile, Contains>(x => x.SearchName, x => x.Name)
.Map<Tile... |
I've written a timer to start when the page loads, and to stop when the user clicks a "finished" button:
<br><button id = "finish" onclick = "stopTimer();">Done</button>
My code works fine, but I was just wondering if there's a simpler/easier/faster way to implement a timer in JavaScript.
//Stop timer function
functio... |
I have a list of lists of numbers. The numbers are in sequential order, ranging from 0 to n and each number only appears once. I want to loop over all the numbers in the list of lists and return the index of the list containing that number.
list_of_lists = [[2,3,4,5,6],[0,1,7]]
desired_output = [1,1,0,0,0,0,0,1]
I ca... |
Recently, during the interview, I was asked to implement basic arithmetic operations with common fractions using TDD. The task is fairly simple, but I was nervous so I did not do too well. :) Later on I decided to give it another try in more... comfortable environment. Here is what I came up with.
Tests:
[TestFixture]
... |
This accepts values from a user that needs to show up in a intervals of some number. In this case, we will say intervals of 5.
Is there a better way to do this?
public static int RoundTo(this int value, int roundTo)
{
var midPoint = roundTo / 2.0;
var remainder = value % roundTo;
var result = remainder < mi... |
I'm writing some code that helps me deal with units better, by having a user defined type for things like Metres, Centimetres and Millimetres. Here is the class declaration for Metres:
template <typename StorageType>
class Metres : public Unit<StorageType>
{
public:
static Metres fromMetres (StorageType metres) noe... |
Overall, I'm working on a simulator for a modified DnD 3.5 system. Right now, I'm trying to write an enum class that handles the Classes/Professions, and am currently trying to handle the profession modifiers for saving throws.
My issue is that everything is extremely boiler-plate, and I can't figure out a better way o... |
I have created a script that handles the responsive liabilities of my HTML menu. The menu will have a variable amount of <li class="menu-item">, resulting in a variable total width. I have 3 functions.
This function is responsible for looping through each li element and calculating the greatest width of the set of elem... |
The demons had captured the princess (P) and imprisoned her in the
bottom-right corner of a dungeon. The dungeon consists of M x N rooms
laid out in a 2D grid. Our valiant knight (K) was initially positioned
in the top-left room and must fight his way through the dungeon to
rescue the princess.
The knight has ... |
I am fairly new to C++, and to have a break from all that Java programming, I decided to do something in C++, which is sorting. The four sorting algorithms are:
Bubble Sort
Insertion Sort
Quick Sort
Merge Sort
Code:
#include <iostream>
#include <ctime>
#include <cstdlib>
#include <iterator>
#include <chrono>
#define... |
This is now my new code implementing the recommendations from my previous question.
import os
import time
import mysql.connector
import MySQLdb
import ConfigParser
import base64
import logging
from logging.handlers import TimedRotatingFileHandler
import sys
import ast
import smtplib
from sendmail import send_mail
"""... |
Based on the previous question, I have utilized most of the answers.
The code is now fully compatible with the STL by implementing forward iterators to store and retrieve values.
Using raw pointers instead of smart pointers
The code is working as expected. I would like to know if my implementation is correct and ho... |
I have been worked on creating a chat tool similar to vk.com. Right now I have done a simple chat which requires only authentication via a PHP website and everyone can chat with each other. I used the NodeSession PHP class to access the PHP session in the node.js application.
To implement the application I used Yii1, n... |
I'm a C++ beginner and I was told to make a program to arrange three integers from least to greatest. How did I do?
#include <iostream>
using namespace std;
int main()
{
int x = 0;
int y = 0;
int z = 0;
int first = 0;
int second = 0;
int third = 0;
cout<<"Enter three integers to be arrange... |
The monkey-banana problem: There many variations to this problem, but the basic premise is that a monkey is in a room with a banana and
a chair, and the monkey cannot reach the banana until he moves the
chair close to the banana (so as to reach it), then climbs the chair
and gets the banana.
(Note : Often times,... |
Given K descriptions for bus line paths that exists to lead students between N campuses. What is the minimum cost that a student will have to goes from campus 1 to campus N ?
The itinerary of each path L is a sequence of |L|( ≥ 2 ) campuses {C1, C2, …, CL}, and each line has only one bus, which passes by all campuses ... |
I want to import a CSV file and do some operation on it.
The following is the code I'm using and it is working fine:
return function (req, res) {
var rl = require('readline').createInterface({
input: fs.createReadStream(myFile.csv)
});
var lineNumber = 1;
rl.on('line', function (line) {
... |
For the request object in my PHP application, I need to dissect the URL and assign its components to class attributes (module, controller, method and the rest are parameters). Currently, I'm doing it like the following but that looks ugly to me. Are there any better ways?
$urlComponents = explode('/', $requestUrl);
if... |
I'm looking for a general peer review on already working code. Just the overall structure and of course any gotchas like DRYness or logic issues.
var AccountExistView = Backbone.View.extend({
Name: 'AccountExistView',
el: $('#ue1_box'),
E: {
ue1_box: '#ue1_box',
// labels
u... |
This is my first step into Fortran. The program aims to provide a simple way of calculating numbers. Just looking for improvements in general.
program Calc
real :: a, b, additionAnswer, subtractionAnswer, multiplicationAnswer, divisionAnswer
print *, "George Gibson's Calc"
print *, "Type the first number: "... |
As part of a larger project I've created recently a simple CssBuilder and CssParser. It's composed of three classes and can parse/build inline and block CSS. Its main purpose was to render CSS for inline styles for email formatting (which is the rest of the project (maybe another time)). I also tried to design a fluent... |
From this hackerrank:
Problem Statement
The Head Librarian at a library wants you to make a program that
calculates the fine for returning the book after the return date. You
are given the actual and the expected return dates. Calculate the fine
as follows:
If the book is returned on or before the expected retu... |
I have a code to check if one shape (circle or square) envelops another. I have used this code. It gives true if the this object envelops the passed shape. Can anyone suggest me an improvement or better alternate method?
public boolean envelops(Shape s) {
boolean flag = true;
double distance = 0.0;
if(s instanceof Squ... |
Essentially I have a server that will be listening for sockets in other programs seeking a connection:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <sys/wait.h>
#include <signal.h>
#include <s... |
My input is basically a .png image from the img/ directory (I figured out that I should parse it, because there is an exploit possible at the moment) and a color which I want to be applied to the image.
The RGB color of every pixel from the image and my input RGB color are being converted to HSL, the H value from my in... |
Given a natural number \$n\$ (\$1 \le n \le 500000\$), please output the
summation of all its proper divisors.
Definition: A proper divisor of a natural number is the divisor that is strictly less than the number.
e.g. number 20 has 5 proper divisors: 1, 2, 4, 5, 10, and the divisor
summation is: 1 + 2 + 4 + 5 + 1... |
I'm making a prime number scanning algorithm in Java. It uses the concept of the Sieve of Eratosthenes to efficiently find the prime numbers.
It works well and can calculate all the prime numbers under 1,000,000 in less than a second on my laptop, but I was wondering how the algorithm could be further improved.
public ... |
This is a simple non-fair semaphore implementation using Java atomic objects. It currently performs a little over twice as fast as java.util.concurrent.Semaphore on my simple test.
The busy-wait loop in acquire() calls the Runnable specified during construction, so that users can provide their own custom back-off strat... |
I'm using Angular Smart Tables with data that might become a huge set of documents and rows. So rather than client side processing of the data for pagination, I borrowing code from two Mongoose.js plugins, put together a plugin to do server side processing for pagination with Angular Smart Tables. The plugins I used ar... |
I have an AngularJS function that is used to determine which $scope associative array variable is to have data pushed into it. I would love to be able to remove the switch case entirely if possible but haven't been able to envision a way to do that! My overall goal is to both improve performance, but more importantly r... |
I've been working on a implementation of specialty tree structure called a BK-Tree (more here and here). Basically, it's a tree that allows relatively efficient querying for items within a specific edit-distance (in my case, Hamming distance).
Anyways, it works, but currently with a tree of ~8 million items, a single q... |
I have a large numpy array of shape (n,m). I need to extract one element from each row, and I have another array of shape (n,) that gives the column index of the element I need. The following code does this, but it requires an explicit loop (in the form of a list comprehension.):
import numpy as np
arr = np.array(rang... |
I built an app where a user has a recipe box with recipes in it - for the db, there is a user and recipe model, user has "recipeBox" property. The recipebox is an array of objects like so:
User model....
User.recipeBox = {
["id1", "done": false],
["id1", "done": true],
}
The done property is for a checkbox on the fro... |
See the previous and initial iteration.
I have incorporated almost all the suggestions by Peter Taylor:
The actual method returns a BigInteger instead of String.
The actual method can deal with Fibonacci numbers with negative indices, so there is no any need to throw IllegalArgumentException.
The only base case that i... |
I'm solving this in perl:
https://github.com/kennyledet/Algorithm-Implementations/tree/master/100_Doors_Problem
Puzzle:
There are 100 doors in a long hallway. They are all closed. The first time you walk by each door, you open it. The second time around, you close every second door (since they are all opened). On th... |
Solving a 4Clojure problem, I got this answer to compress a sequence (problem 30):
#(map first (partition-by identity %))
What would be the best approach to have this work with plain numbers too?
My solution was this:
(defmulti comp class)
(defmethod comp java.lang.Long [x] x)
(defmethod comp :default [x] (map first (... |
I've been learning Processing for the last week or two, and I've made a couple of little 'desktop toy' type apps like this one that I'm quite pleased with. However, it just occurred to me today to look at the activity monitor while my app was running, and I was unpleasantly surprised – nobody wants a desktop toy that's... |
I have made the bold claim that a longstanding problem in Rebol is "now solved"...that of "definitional returns".
But of course, such claims need some peer review, and there's always some new trick to learn or improvement to make. So I thought I'd paste some code here. Even though it doesn't tell the full story of w... |
I don't have a strong mathematics/Matlab background. I would like to convert this Black level correction function from Matlab to C++. Please comment about on the code style and correctness of my equation.
Matlab
function output = calculateBlackLevel(blStruct, AG, ET)
blLut = zeros(length(blStruct), size(blStruct... |
I'm working on a small application that uses a WebService to get meta-data about television episodes. What I'd like to do is start building out a local cache of the series so that I can reduce the number of calls to the service. Data being stale is not a concern at all for this case. I've chosen to use an XML file t... |
I am developing a service where the user need to sign the seller agreement with Mobile BankID (Swedish e-sign service). To make this work I need to make SOAP request to get the progress status of the signing request in Mobile BankID.
Is this code understandable? How can I make it more clean?
def collect_request(transac... |
I have tried to implement the DFS algorithm to find all the back-edges in a graph that lead to a cycle in the graph:
public class CycleDetection {
private final Deque<Node> stack;
private final Graph<Node> graph;
private final Set<Node> visited;
public CycleDetection(Graph<Node> graph) {
super(... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.