instruction stringlengths 71 39k |
|---|
A lottery draw consists of choosing 6 different values from 1 to 50.
I want to calculate the number of combinations with gaps of at least 3 between every pair of values.
I have used the following Python 2.7 script:
def func(array,length,min,max,gap):
if len(array) == length:
# print array
return 1
... |
I have written a multi-language software to implement an image denoising algorithm (composed of many sub algorithms) called CANDLE. I have a C program that is part of the software and would like to make sure that it is adequately optimized and safe.
It is a simple C program (no multithreading). I have ran it and everyt... |
I intend to make some changes in an HTML document, like remove, replace, append some nodes.
I have several arrays with same structure like the following example
$patterns[] = array(
'xpath' => '/html/body/div/p',
'insert' => $new_a,
'task' => 'replace'
);
...
$patterns[] = array(
'xpath' => '/... |
The exercise is:
Adapt the ideas of printd to write a recursive version of itoa; that
is, convert an integer into a string by calling a recursive routine.
I wonder if I have correctly answered the question.
# include <stdio.h>
# define MAX 100
int itoa (char s[], int n)
{
static int i = 0;
if (n < 0) {
... |
This is my forms.py for a small survey application I am developing. I previously posted some of my models.py.
I am completely self-taught and am just looking for advice on how to improve. Any advice, even things you might think should be obvious, would be much appreciated.
from django import forms
from django.forms imp... |
Here's what I managed to do. It is rather limited and I had to get help from the internet in some places.
Can you review it, give me some tips on making the code better, cleaner, faster etc.?
editor.py
import tkinter
import tkinter.ttk
import tkinter.filedialog
import tkinter.messagebox
import os
try:
import confi... |
I'm trying to solve Codeeval's The Ministry of Truth challenge, and have hit 97.5% - is anyone able to spot where my code is missing the last 2.5%? The percentage indicates that one or more of their test cases is failing.
Here's the question - I've used the original wording because I'm worried if I give my version of t... |
I have developed a small survey application in Django 1.6.2 which requires that the participants fill out a number of questions over 27 pages using a SessionWizardView.
Overview
The most unique feature of the application is that it allows the user to rate a selection of 9 images selected at random in isolation. The use... |
I am writing a Type-ahead / Autocomplete search with angular using directive and filter service. I am almost there but need your expert opinions on things which I am planning to achieve.
Git Repository
@Todos:
Look and feel
Allow navigation using keyboard
Enter and Esc key handling
Could anyone review and suggest mor... |
A while ago, someone at our office thought it'd be a great idea to start tracking a number of fairly large binary files in one of our more important repositories. We noticed our builds were slowing down (considerably) and fetching new changes from the remotes could take for up to a minute.
We eventually noticed that th... |
I am translating Matlab code to OpenCV. The code involves lots of reshaping of large matrices. As the Matlab reshape differs from OpenCV you can't just use OpenCV reshape.
Here is why: Let's suppose we have a 2x4x3 matrix such as this:
a(:,:,1) =
1 3 5 7
2 4 6 8
a(:,:,2) =
9 ... |
I am learning Haskell and as exercise I am doing Project Euler Problems. In this case PE1.
-- Sum any given finite Airthmetic Progression
sumAP :: Integer -> Integer -> Integer -> Integer
sumAP first limit step = do
let last = limit - (limit `rem` step)
let terms = (last - first) `quot` step + 1
let avg = firs... |
I myself is a Java-developer and now I'm trying to understand how to do it in the most efficient way in C++. After reading that answer I decided to write the following:
//Headers omitted
class integer_validator
{
public:
integer_validator(const char* const str);
bool is_valid();
long get_number();
private:
... |
I am filling a bag full of scrabble tiles. There should be 100 tiles in the bag of these letters:
A-9, B-2, C-2, D-4, E-12, F-2, G-3, H-2, I-9, J-1, K-1, L-4, M-2, N-6, O-8, P-2, Q-1, R-6, S-4, T-6, U-4, V-2, W-2, X-1, Y-2, Z-1 and Blanks-2.
These numbers/letters should never change. I have a working solution, but i... |
This is a generalized A* pathfinder in Go. I am new to the language and am eager for advice about best practices.
In particular, I am not sure if the type assertion I make in Heuristic is the correct way to bind the implementation to the interface.
I have stolen the PriorityQueue type from the package documentation for... |
I have developed a simple autocomplete module for search box in ecommerce website (http://www.cjcharles.com/) built over shopify. Now, as the CMS is commercial, I was forced to use its given API's only.
/*
The given function implements instant search for ecommerce websites
built on shopify platform usin... |
I decided to implement the std::vector class in C++, and was wondering if I had done everything correctly. When I mean 'correctly', I mean that the code is efficiently written and done properly. I have tested all the functions using various tests and they seem to output correct results.
I have not included every functi... |
I saw this question and thought it looked like a great opportunity to try my hand at the Strategy Pattern. I've never used it before, but I think I did pretty well. Did I?
The code below can also be found on github. I'm using C# 6.0 for this, so if there are any opportunities to use new features that I missed, I'd lik... |
Problem Statement:
You are given a function \$f(x)\$, where \$f(x)\$ is \$1\$ if the first and last characters of string \$x\$ are equal; else it is \$0\$.
You are given a string \$S\$ and you have to find the sum of \$f(x)\$ for all substrings \$x\$ of given string \$S\$.
Sample Input:
7
ababaca
Sample Output:
1... |
I began this month with trying to discover how shellcode is made. My search led me to wanting to learn assembly, so I wrote a simple bootloader with NASM:
bits 16 ; 16 bit real mode
org 0x7C00 ; loader start in memory
start: jmp main ... |
I am working on a RestService in which my URL will take lot of parameters. Below are the parameters my URL will take:
UserId: This should always be a long and a number in general.
DeviceId: This should always be a String.
PetaId: This should always be a String.
FlowId: This should be a long as well and a number in gen... |
Many numbers can be expressed as the sum of a square and a cube. Some of them in more than one way.
Consider the palindromic numbers that can be expressed as the sum of a
square and a cube, both greater than 1, in exactly 4 different ways.
For example, 5229225 is a palindromic number and it can be expressed
in e... |
I made a chat bot, that, as you talk to it, it learns to respond. But the way it speaks is strange, so if you have any ideas on how to make its response any more human, then please say so.
Anyway, you have to start a new chat bot. You'll notice that when you start his responses will be incredibly stupid. Once you talk ... |
I have to draw various instances of HeatMaps, Winds and Polylines. Each layer will have one HeatMap, 1000+ Wind arrows and 3000+ Polylines.
The websocket pushes the data into the mapData structure where the data is stored for later manipulation of objects.
Each layer takes around 400MB of memory. Since I have to draw m... |
I'm basically looking for a general critique. I'm just starting out and would like to know if I should have done anything differently to make it faster or to make it much more readable. I don't know exactly what happened but I tried it with 14 iterations and it took about 3 minutes to complete. It crashed Unity at 15 a... |
See the previous and initial iteration.
See the next iteration.
I have mainly refactored the code and made it a little bit robust (if serialization of a single object produces a string with new line character(s), an exception is thrown as the deserialization routine relies on assumption that the object string represent... |
I am building game, like Ogame, or Ikariam where you can play with other users in real-time. You train some soldiers, and build some vehicles or buildings. Every building or vehicle has some level. If a building has a higher level you must wait longer to use it etc. I will be grateful for any comments, especially about... |
I wrote the following snippet to deal with a situation in which I have two datasets (usually the current version versus a previous one) and I need to identify what changes have occured: usually explaining the deltas of one specific column.
I want to identify what rows have been added, what rows have been removed as wel... |
For practicing purposes, I challenged myself to write a program that solves the TSP and visualises the results step by step.
As for now, my program uses a simple nearest neighbour algorithm. I want my program to be flexible, so when I add a new algorithm, it will be able to visualise the results, too, without messing w... |
The Problem
Given a list of dependencies ('a * 'a) list where the first item has a dependency on the second item, construct a dependency graph and then 'flatten' it into a single 'a list such that no item comes after one of its dependencies.
Constraints
I am trying to improve my functional programming/idiomatic F#, so ... |
I have this code that creates (or updates) a user from an omniauth hash parameter:
def self.find_or_create_from_auth_hash(auth_hash)
uid = auth_hash['uid']
provider = auth_hash['provider']
user = find_or_create_by(uid: uid, provider: provider)
user.name = auth_hash['info']['name'] || ''
user.ema... |
Inspired by Minimising the triangle
I am writing a fully tested program to solve the following problem:
A triangle needs a good foundation. Every row in the triangle is derived from the sum of the two values below it. However, there can be
no repeated values, if a value shows up more than once the triangle
crumbl... |
I've written a little program to calculate pi using the Nilakantha series:
For this formula, take three and start alternating between adding and subtracting fractions with numerators of 4 and denominators that are the product of three consecutive integers which increase with every new iteration. Each subsequent fracti... |
The expected functionality is that a user/vehicle interacts with a ParkingLot and it allots the space in Park method based on type of vehicle (here I can expect a few changes, like increase from regular and handicapped to one more functionality for celebrities etc). What would be the route to perfect object oriented co... |
A few years ago I modified version 1.8.1 of Jason Blevins's markdown-mode for Emacs so that when showing inline links the URL is hidden, and so that you can follow the link simply by hitting Enter. If you want to see the URL you can still see it by, say, removing the final ). It's based on linkd, though I'm told that o... |
The prompt that made me put this function together was sourced from CodingBat.
I was curious about cleaner, more correct methods of doing putting this together such as finding a cleaner way to tell if there is or is not a duplicate in the array. I am also trying to be as efficient as possible. I believe this is an \$O(... |
I have just installed Ubuntu and am re-familiarizing myself with Python. I learned the basics in late 2012-early 2013 and I'm practicing with it in order to get better at programming concepts and practice.
'''
Snake Game
implements gameplay of classic snake
game with Tkinter
Author: Tracy Lynn Wesley
'''
import threa... |
Is it possible to declare multiple arrays in PHP in one line?
$userAnswers = array();
$questionIDs = array ();
$sqlAnswers = array();
$sqlAnswersQuery = array();
$correctAnswers = array();
Any cleaner ways of doing this?
NOTE: The contents of these arrays are all DIFFERENT. I don't think setting them equal to each ot... |
My colleagues often ask me, "Dude could you remind me what I have to type to build this target?". So I eventually implemented a nice workaround in my Makefiles.
I wanted my Makefiles to have a help target that give some usage clues to the users. This is achieved with an embedded Perl script and some markers.
Wherever ... |
The following snippet will return a list containing the words in all of the works of Shakespeare:
>>>def shakespeare_tokens(path = 'shakespeare.txt', url = 'http://inst.eecs.berkeley.edu/~cs61a/fa11/shakespeare.txt'):
"""Return the words of Shakespeare's plays as a list"""
import os
from urllib.... |
I have this one single line of code I wanted to improve. My main concern is the execution and rendering speed of it. Even though I am happy with its speed, could it be improved?
document.getElementById('my-webpart').style.height =
(document.documentElement.clientHeight - 80) + 'px';
The reason I didn't ad any variabl... |
While writing a review of @MotokoKusanagi's Brainfuck interpreter, I decided to write my own implementation to illustrate a few points. In particular, I'd like it to be robust to malformed programs, and reasonably efficient (short of JITting the Brainfuck code).
Please point out any deficiencies you might find in this... |
My previous post had no response, so there is part of the whole - levels service. It stores levels with it's attributes. I'd like to hear any suggestions about code readability and code performance.
(function() {
'use strict';
angular
.module('app.mine')
.service('levels', LevelsService);
... |
I load a table in a div using the .load() method. If I look on the console I see the times taken to display the table:
4.98 seconds that firebugs says are spent "waiting" for a response (from a PHP backend)
9.94 seconds receiving data.
During the second event I see that the browser throws an alert saying that the scr... |
I have created an app in which URLs stored in a database are pinged via curl to check their availability and the database is updated with the results.
Two tables are updated with each fresh ping of a website (Site -- the status recieved 200, 404 etc) and (History - time of each ping, time taken, result etc) From my und... |
I have started putting together a functional programming library in C# which is somewhat inspired by scalaz and the book Functional Programming in Scala.
I am hoping to get some feedback on the Monad Transformers implementations and comments.
Please understand this is implemented in C# and .NET, which does not support ... |
I have a "generic" cache object:
public class Cache {
private static final Map<Class, ICacheable> cacheMap = new HashMap<>();
public static ICacheable getCacheableElement(Class cacheableElementClass, Object... params) {
ICacheable cacheableElement = cacheMap.get(cacheableElementClass);
if (cac... |
I have a lot of filter classes which are named after the method names they filter by.
For example:
OrderByBestValueFilter corresponds to #best_value
OrderByPriceFilter corresponds to #price
and so on...
Since I'm doing a lot of these transformations, and the point of this set us is to make filters easy to add or ... |
I'm very new to SQL, but I'm coding a C# program that interacts with a database. There's a master database on my computer, and there's a client database on my tablet.
When I re-connect my tablet to the network, I want it to merge the two databases, so that changes made on the tablet are pushed to the master, and chang... |
#include<iostream>
#include<string>
using namespace std;
int main()
{
string s, sub;
cin >> s;
int check = 1, count = 0, pos = 0; // keeping count of number of alphabetical ordered substring characters
int i = 1; // loop variable
int prev = 0; //to hold previous value of loop variable
while (... |
I know there must be a better way to perform the above sub than using multiple If statements. I was thinking of storing the obj.PropertName into a collection and run it through a for loop.
'Create instance
Dim wellObj As CWell
Set wellObj = New CWell
.
.
.
Private Sub Well_List_Click()
'Must check if null..
I... |
I've found that the function genfromtxt from numpy in Python is very slow.
Therefore I decided to wrap a subroutine with f2py to read my data. The data is a matrix.
subroutine genfromtxt(filename, nx, ny, a)
implicit none
character(100):: filename
real, dimension(ny,nx) :: a
integer :: row, col, ny, nx
... |
I think the inherent relations in this query should be self-evident:
ShipmentStatus.joins(shipment: :shipment_users)
.where("shipment_users.user_id = ?", user.id)
I have a feeling there's maybe a shorter way to express this. Can it be reduced?
|
I put this together and am having some doubts to the number of connections I can make. I also doubt if I can brute force the server to serve up connections and then hang.
Please take a look and tell me what I can do better.
'''
Simple socket server using threads
'''
import socket
import sys
from thread import *
... |
Basically, I want to write a huge file of numbers. Each line in that file should contain one number. This program below is extremely slow (obviously) but it works. It writes one line after line and always one number until the limit of an unsigned long has been reached.
#include <iostream>
#include <limits>
#include <fs... |
Is the trade-off between simplicity and performance worth it?
def is_sorted(list_):
"""
Is the list sorted?
The simpler `list_ == list(sorted(list_))` has
time complexity O(N log N), this O(n).
>>> is_sorted([1, 2, 3])
True
>>> is_sorted([1, 2, 7, 3])
False
"""
return all(curr ... |
The problem is that I'm checking if result from cursor exists in CDN.ZamNag table for every iteration. Is there any better way to check if values in table 1 are also in table 2?
Time of executing below procedure takes 1 minute and 30 seconds - I'm searching for any ideas which will make executing shorter.
IF (SELECT ob... |
See the previous iteration. See the next iteration.
I emphasized the fact that serialization routine may not return a string with new line character by using more or less explicit identifier. Moved the actual de/serialization routines to a factory class. That's what I have:
LineStringSerializationFactory.java:
package ... |
I have black Raw Bayer Images RGGB color space. I want to go over each pixel in their channel and sum them up for each channel, then divide it by the number of pixels for each channel. I'm trying to build a fast optimized algorithm.
Here is how I have started. The code runs but I still have some issues with the results... |
I wrote a series of questions in a previous post, and a user recommended that I separate the questions.
I have made the switch from procedural programming to object-oriented programming. I have grasped/utilized the benefits of OOP, but I am still struggling with the placement of the business logic for the application.
... |
As the name says, LongModulus is a pretty long (lengthy) class implementing modular arithmetic for a long modulus. As overflow is a problem, I implemented two subclasses, one for moduli not using the highest non-sign bit (i.e., smaller than \$2^{62}\$) and one for the others.
The code uses Guava and Lombok. As usual, f... |
I'm working on The Python Challenge. The current code iterates over a 98,766-character string before printing an 8-character string. Current execution time is between 7 and 10 seconds.
How can I optimize my current code and what rookie mistakes am I making that may be adding to the execution time?
import urllib.request... |
This code counts down from 30 to -999 on a 7-segment 4-digit display; it works but I don't know if it is a good way to do it or if it follows best practices. I want to start writing libraries for components that are not specifically made for Arduino. This is my first attempt. Please tell me if there are any problems... |
I need to parse the data coming from the URL which looks like this:
hasProcess=true
version=1
DATACENTER=abc
TotalNumberOfServers:4
primary:{0=1, 1=2, 2=1, 3=2, 4=1, 5=2, 6=1, 7=2, 8=1, 9=2, 10=1, 11=2, 12=1, 13=2}
secondary:{0=0, 1=0, 2=0, 3=1, 4=0, 5=0, 6=0, 7=1, 8=0, 9=0, 10=0, 11=1, 12=0, 13=0}
host... |
This is a simple piece of code which takes two arrays supplied as parameters, then appends them to a new array that contains the values from the supplied arrays. Any suggestions for improvement would be greatly appreciated.
public static int[] append(int[] list1, int[] list2) {
int[] appendedList = new int[list1... |
I'm working in a game as a hobbie. I'm using an Entity/Component/System architecture using Libgdx as Engine and Ashley as Entity Framework.
I have a GamePlayScreen in which I initialize my system, creating Entities, Systems and Components. Below is a tiny code snippet of class constructor with the calls to severals 'c... |
To aid in the localization of .resx files, I made a generic resx comparer that allows you to edit the values of the resx's. Also, this is my first proper adventure in WPF (I've just been using Windows-runtime before).
This is my view interface:
public interface IResxTranslationHelperWindow
{
object DataContext { ... |
I asked this question and I have made enough changes, so I think it deserves a new question.
The Problem:
A triangle needs a good foundation. Every row in the triangle is derived from the sum of the two values below it. However, there can be no repeated values, if a value shows up more than once the triangle crumbles.... |
I am exploring different ways of implementing a linked list in Rust as a learning project. In one particular place, I've got some code that works properly, but it makes multiple calls to unwrap--I am under the impression this is generally regarded as unsafe/poor style. I'd like to make it better.
Here are some releva... |
I have implemented the K-Nearest Neighbor algorithm with Euclidean distance in R. It works fine but takes tremendously huge time than the library function (get.knn). Please point out the possibility of improvement.
knn<-function(list,k){
n=nrow(list)
if (n<=k) stop("k can not be more than n-1")
neigh<- matrix(0,n... |
My first use of classes with Python. Very simple code which I feel may be further simplified. Please break my code or give me input on where it could have been better/efficient.
import maya.cmds as mc
from functools import partial
class MoveSelTool(object):
'''Tool for moving selected object or objects by a
v... |
The code below is pretty self explanatory: just copy and paste it all into a module and run it, it provides a few use cases and many explanatory comments in the text. (It works but I'm interested to know what other people make of it and for any suggestions you might like to make.)
The most important facts to realise ar... |
The file I'm processing here is an outputted file from a Java library called duke.
Its goal was go through all purchases made on a site and group them into a single customer. The output is a csv file in the format, you'll find an example of it below the code.
I want to know if I've written this in a readable way or if... |
I was assigned a task to make a simple jar that can handle 2 console commands -> create key value, read key. I have 4 classes, where my main logic is implemented. Eg. create bulgaria sofia, creates a record in a serialized file with a key - bulgaria and value - sofia. Any feedback about the code and the idea are more t... |
I wrote a code in Python to solve Knapsack problem using branch and bound. I tested it with the case from Rosetta and it outputs correctly. But this is my first time to write this kind of code, I am feeling unconfident. Could you please review my code and give me some tips to improve it?
A tourist wants to make a good... |
I have very little experience with C, so I decided to code a simple numerical program.
An Armstrong number with \$N\$ digits is a number that is equal to the sum of its digits to the \$N^{th}\$ power, in pseudo-code:
sum { power(digit, N) for digit in number } == number
My program finds all the Armstrong numbers below... |
I wrote some C++ code using the OpenCV library. The program reads the image and plot histograms of Red, Green, and Blue components. I am very new to OpenCV so I need comments and advice. What do you think about my code? Is there any better way to do that? Are there unnecessary parts in my code? Is there any part I shou... |
I need to round numeric values for properties of a given object.
The following code works fine, but I am concerned if there is a way to make it faster.
I am targeting latest Chrome and Firefox.
http://jsbin.com/bahedegoni/edit?html,output
window.app = {
start: function () {
var cmd = {
... |
Having read most of Learn You a Haskell as well as parts of Real World Haskell, I decided to embark on an easy project to see if I can apply the Haskell that I've learned.
{-# LANGUAGE OverloadedStrings #-}
import Data.Maybe
import Text.Regex.TDFA
import qualified Data.ByteString.Char8 as B
main = do
dictionar... |
My program uses the Knuth–Morris–Pratt algorithm to search for a particular substring in a .txt file and then store it in a binary search tree.
Note that testfile.txt should be contain only spaces and normal characters (no newlines! - except maybe as the last byte).
There is a lot of code, so note that I am primarily c... |
When you own an Android device and want your iTunes playlist to be copied over onto it, what do you do?
What if your playlist hits something in the region of 20GB+ ? Well, I am sure I could've paid for a tool, to do this for me and keep things in sync, but I wanted to challenge myself into writing something in Python t... |
After reading this, I'm on board, however it doesn't get into passing methods from the parent class. In my mixins right now I have a lot of helper functions that are used across the various components that use the mixin.
I would simply do something like below, unless someone has a better approach? Note I have anywhere ... |
I was given a tech test for a prospective job a small game that uses Facebook API to connect a user then to guess the image. The feedback from the employer was good but they said they had to modify part of my code to get the API connection working even though the demo app works fine. This has caused them to lower the o... |
I'm trying to have the 3 buttons to each open its own list below whilst closing any current active lists open. I've tried my best with jQuery, but it seems so bloated. Is there a way to streamline this?
At the moment I have a very rough working example:
/***********************
Mobile Menus
************************... |
I wanted to center some text in my commandline application, so I came up with this function.
centerText(){
textsize=${#1}
spacecount=$(tput cols)
spacecount=$((($spacecount-$textsize)/2))
while [ $spacecount -gt 0 ]
do
printf " "
spacecount=$((spacecount-1))
done
printf "$1"
echo
}
If you have suggesti... |
I'm trying to have the 3 buttons to each open its own list below whilst closing any current active lists open. I've tried my best with the jQuery, but it seems so bloated. Is there a way to streamline this jQuery code?
At the moment I have a very rough working example.
/***********************
Mobile Menus
***********... |
I'm making a really simple html website with CSS and I was hoping on some feedback. A few notes:
There will be more content under this, but I want the starting screen to take up the full page and then scroll under it.
I've used a bit of a hack to remove the padding from the first list element
I've used a bit of a hac... |
I'm just at the beginning stages of making a simple chess engine. I have a function that when passed the x and y coordinates on a 2D list can enumerate all possible moves for a piece. It assumes there are no other pieces on the board, and that all moves are possible (see example list of moves below) and a separate func... |
This code validates the following:
enddate should not be less than or equal to startdate.
startdate should not be less than or equal to the date today unless document.getElementById("ltype").value == "1".
The maximum gap between startdate and enddate is one year, more than that should cause an error alert.
Please rev... |
My goal is to remove whitespaces from string elements of my list, and to remove empty string elements altogether. My code:
def modifylist(lst):
lst = [elt.strip() if type(elt) is str else elt for elt in lst]
while '' in lst:
lst.remove('')
return lst
Is there any other method th... |
I have the following code:
for j in range(rows):
for i in range(cols):
k = j * rows + i
k1 = k + 1 if i < cols - 1 else k - 1
k2 = k - 1 if i > 0 else k + 1
k3 = k + cols if j < rows - 1 else k - cols
k4 = k - cols if j > 0 else k + cols
w1 = U[k]
w2 = U[k-... |
A tourist wants to make a good trip at the weekend with his friends. They will go to the mountains to see the wonders of nature, so he needs to pack well for the trip. He has a good knapsack for carrying things, but knows that he can carry a maximum of only 4kg in it and it will have to last the whole day. He creates ... |
I am writing a solved for 15 puzzle game which will find the solution path to any NxN board. For easier boards the algorithm works great solving almost any 3x3 boards, most 4x4 boards, but when I go 5x5 and higher I will often run out of memory. This is the implementation:
@WorkerThread
public Solution findPath(Board b... |
I was solving this question on a site that gives you a 1d array called grid
grid = ['top left', 'top middle', 'top right',
'middle left', 'center', 'middle right',
'bottom left', 'bottom middle', 'bottom right']
and you're expected to write a method fire(x,y) that takes in two coordinates ... |
I've seen a lot of Brainf**k interpreters in various languages. I decided that actually interpreting Brainf**k is too hard, so instead of that, I wrote a 'compiler' in Ruby that directly transcribes BF to Ruby code. This is Version 1.0, and I'm looking for any tips on how to make it more efficient.
There are a few thin... |
I'm sending data from a form with a variable number of fields via an Ajax call. Some of the fields are grouped together so I have opted to send them as an array of JSON objects to keep the groupings, but there are a number of ways of doing this. For client-side, is it better to read the form as JavaScript objects and ... |
The algorithm works in steps:
Produce the graph in the form of an adjacency list
e.g. this graph
0 - - 2
\
1 -- 3
produces this adjacency list
{0: [], 1: [0], 2: [0], 3: [1, 2]}
0 depends on nothing, 1 depends on 0 etc..
Iterate through the graph and find nodes that does not have any dependencies
Question... |
I'm in the process of refactoring one of my open source projects, branch here.
The basic idea of the refactor is to allow for classes and all of its children in the graph to be scoped. I wrote a blog post about it here.
The container is abstracted into an interface:
public interface IScopedContext : IDisposable
{
}
... |
This code feels long and clunky to me. How can I make it shorter, if possible?
I am writing for a libGDX game, and I need a skill algorithm.
I want it so once the player picks up something (which I already have checked for) I set a, b or c to a certain SkillType, the enum down below. Then, I want to get the value of th... |
Based on a question on SO I thought I'd knock up a cmdlet to perform an unpivot on an object. I've not yet considered all the options (e.g. what happens when objects with empty lists are passed), so there are likely a few issues, but I wanted to get it out to the community early / see if people think this is useful or... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.