instruction stringlengths 71 71.9k |
|---|
I'm currently working my way through a textbook to enhance my beginner Python skills (Goodrich, Data Structures and Algorithms in Python). The first, somewhat in-depth problem involving OOP was the following:
Write a Python program to simulate an ecosystem containing bears and
fish. The ecosystem consists of a river... |
I wanted to make something for the Community Challenge, so I made a simple permutation and combination calculator. I'd like input on:
The overall design - any suboptimal choices that could be improved?
Naming - This is hard, I know. But is it confusing to follow? Some names seem repetitive, others seem overly long.
An... |
I want to improve my code or structure. How does it look? Any comments or suggestions?
$(function() {
function searchGit() {
//grab value of search field
var search = $('#search').val();
// Validates entered value
if (search.length > 0) {
//pull json data from url
... |
I applied for an Application Developer position. They require all their applicants to complete 1 of 3 programming assignments. I picked one for sales tax calculation. It was quite simple.
Write a program the feeds in prices. If the item is a Book, Food or
Medical product there is no tax, if not there is a 10% t... |
I want to implement the following function:
Given a target sum, return the combination that equals the target sum and is the most efficiënt combination in the array of an ArrayList.
For example:
An ArrayList with the values 9,3,4,6,4,2,1
Then it will return the best possible combination.
You can add 9 + 1, which ret... |
Q. Write three similar functions, each of which takes as an argument a sequence of intervals and returns the sum of the square of each interval that does not contain 0.
Using a for statement containing an if statement.
Using map and filter and reduce.
Using generator expression and reduce.
Hint: Square is a special ... |
I have to make a simple program that reads N integers from the user and counts the occurrences of duplicate items. I know that the chosen sorting algorithm has poor performance, but I chose it for its simplicity.
I'm looking for suggestions for the last part, in which I count the duplicates.
#include <stdio.h>
#define... |
Is this acceptable? What is the next step to improve algorithm and make them more clear and faster?
typedef struct heap_block
{
struct heap_block* next;
size_t size;
bool isfree;
int x; // for alligment
}header;
#define Heap_Capacity 16777216
unsigned long long active_size; // # bytes in active allo... |
(Largest block)
Given a square matrix with the elements 0 or 1, write a program to find a maximum square submatrix whose elements are all 1s. Your program should prompt the user to enter the number of rows in the matrix. The program then displays the location of the first element in the maximum square submatrix and th... |
I have a .json file with a complex structure: dict in a dict, it has no constant structure and is dynamically changed.
The goal is to make new dict where the keys are numbers of hierarchy and values must be strings that are composed of all previous steps like
2 drinks
2.1 drinks coffee
2.1.1 drinks coffee instant
2.1.... |
I'm working on a complex Javascript application which includes its own data structure. The previous version's data structure was rather chaotic, and I'm looking to replace it with something where:
Every data item is an object which is (effectively) an instance of a class, which imposes a common structure including def... |
I am designing a planetary system simulator. The coordinates used are standard for JPanel (0,0 in the upper left corner).
My model is based on a class Body:
public class Body {
private double x, y; // position
private double w, h; // dimensions for drawing
private double vx = 0, vy = 0; // velocities along ... |
This is a follow-up question of this one: Tic Tac Toe game in Haskell
I have revised my code. How does it look now?
import System.Random (randomRIO)
import System.IO (hFlush, stdout, getLine)
import Data.List (intercalate)
import Data.Array
data Tile = EmptyTile | X | O deriving (Eq)
data Player = Player1 | Player2
... |
This program takes a command line argument of how many times you would like to encrypt plain text. After you compile the program, input a message you would like to have coded. I'm new to C and curious about how to make this program more efficient.
/*
*caesar.c
*
*
*
*Encrypts user supplied messages according to a user... |
I just got the urge to write a small console app to compare all directories name for similarity. I have > 3000 directories and over time some of them are really similar, eg. an update: Test Case ver 1 vs. Test Case ver 2.
Well everything is working but it is really slow, it is probably faster for me to sort the directo... |
Take the below code that I recently wrote:
.navbar-inverse .emphasis-text, .navbar-inverse:hover .emphasis-text, .emphasis-text {
color: #1caa98; /* Teal */
}
While this may be a dryer way of placing teal on all these link items, would you consider this readable? It seems to me like there is a lot to read, and it'... |
I wrote a menu in bash to access network equipment, but now there are too many of them to show in one screen to permit selecting one without scrolling up or down. I need it to be improved.
I've considered having two files:
The list of each equipment. Inside this file are the headers and an ID to determine if equipment ... |
I've written a program in Java that will fetch JSON information from a service through their API and save it. As I'm new to Java, I want my code looking clean as possible and to understand the language's cultural coding standards as soon as possible. I know JSON data is usually mapped to a POJO, but I still haven't bee... |
For one of my cases in algorithms I am required to create a model of a load balancer model for multiple processors. Lately I became interested in Scala so I decided that it would be great to create this program in Scala. I'm not really familiar with the concept of functional programming so any feedback will be welcome.... |
I'm attempting to make a stock trading game in Javascript and I've been trying to find an algorithm to generate fake stock prices. Currently, each Stock object has a minimum value, maximum value, and volatility which I will explain later. The code is as follows:
Stock.prototype.generateValue = function () {
//mod =... |
I was reading about the MIDI spec and I challenged myself to implement a function to convert an int32 to a variable length quantity uint32.
I didn't look it up or anything so there might be a way more efficient or tricky way to get the same result, but as far as doing what I set out to accomplish the following code wor... |
I work in IT compliance and one of my main duties is ensuring the integrity of employee network accounts. Partial VBA script as currently used is shown below:
Public Function validateHireDate(hireDate as String)
If Not IsDate(hireDate) Or IsNull(hireDate) Then
validateHireDate = "Invalid hire date"
Els... |
I'm not sure what is the best way to handle css when I have two uses of a class where the difference is one floats left and the other right.
An example:
img.screenshot{
width:100px;
height:110px;
padding:5px;
}
Do I do this:
img.screenshot.floatLeft{
float:left
}
img.screenshot.floatRight{
float:right;
}
Or this:
.fl... |
I'm going through the Udacity Intro to HTML and CSS course at the moment, and one of the exercises is to convert this mockup to HTML and CSS.
I did the following, and it looks ok-ish:
HTML:
<!DOCTYPE html>
<html>
<head>
<title>Jane Doette / Front-end Ninja</title>
<link rel="stylesheet" href="css/style.css">
</head... |
I wrote a small script that finds the solution to the cracker barrel peg game / triangle game.
Gist
"""A small script that finds the solution to
the cracker barrel peg game / triangle game.
Instructions along with one of the game's solution can be found here:
http://www.joenord.com/puzzles/peggame/
It finds the solut... |
I wrote a basic Minesweeper game for practice. It consist 3 classes:
Main - only as launcher
Cell - controling behavior of single cell
Board - coordinating behavior of cells.
The hardest part for me, was a determining the value of single cells (how many mines is around it), and firing a chain reaction, if some cell ... |
I'm working with the XMLSOCCER.COM API. I'm a little confused with how to best design the application. The problem I'm facing is that teams do not have a league ID so I couldn't associate a team with a league by that.
In order to associate them my league has a List<Team> and Team has List<Player>.
I'm trying to reduc... |
I have made a class for some Netapi32.dll functions in C#. I would like to know if there are any big problems with it or if there is some other function needed in general.
Functions:
NetFileEnum
NetShareEnum
NetFileClose
NetSessionEnum
NetApiBufferFree
Here is the class:
using System;
using System.Collections.Generic... |
This is codeEval challenge to count the number of chains possible to make with beads holding numbers. Constraint is sum of the consecutive beads of chain should be a prime number.
The standard algorithm std::next_permutation is very resource oriented in this case, so dropped the idea to use that one.
I created a simple... |
For the following question, the function
• should mutate the original list
• should NOT create any new lists
• should NOT return anything
Functions that do not create new lists are said to be ”in place.” Such functions are often desirable because they do not require extra memory to operate.
Implement the function map_... |
I am working on a Roman numerals calculator. For an input validity test I'm using this function:
bool isValidRomanNumeral(string& roman){
// no test for one-digit Roman numeral
if (roman.size() == 1) return true;
for(size_t i=0; i<roman.size()-1; i++){
// each more significant digit is either >=... |
Project Euler, problem #50:
The prime 41, can be written as the sum of six consecutive primes:
41 = 2 + 3 + 5 + 7 + 11 + 13 This is the longest sum of consecutive
primes that adds to a prime below one-hundred.
The longest sum of consecutive primes below one-thousand that adds to
a prime, contains 21 terms, and is ... |
I'm looking for feedback on functionality, PEP8, advice, etc as a learning tool. I'm not sure how to tell if this program should be broken into separate functions or combined as one.
While hand editing files for an organization I work for, I made this code having seen an opportunity to simplify "How to Integrate Excel... |
I have the following sample code running unit tests:
#!/usr/bin/env python3
import sys
import unittest
import argparse
class ParentTest(unittest.TestCase):
None
class Test1(ParentTest):
def test_if_verbose(self):
import __main__ # FIXME
print("Success!") if __main__.args.verbose else "" # FIX... |
I have the following code:
#!/usr/bin/env python3
import os, argparse
if __name__ == '__main__':
# Parse arguments.
parser = argparse.ArgumentParser()
parser.add_argument("-v", "--verbose", action="store_true", dest="verbose")
args = parser.parse_args()
try:
verbose = bool(os.environ['VER... |
I am working with Youtube OAuth for the first time and I am not that great when it comes to security. I got the following code and would like to hear if you guys can find any security issue:
$code = $_GET['code'];
$url = 'https://accounts.google.com/o/oauth2/token';
$params = array(
"code" => $cod... |
Back in my calculator post, janos suggested I either find a better way to read a double from a StreamReader or else go the whole way and build a double from scratch. I looked through a few streams, but the only one I found that supported reading a double was the BinaryReader. This, unfortunately, reads exactly 8 byte... |
Given the problem:
You are given a 2-Dimensional array with M rows and N columns. You are
initially positioned at (0,0) which is the top-left cell in the array.
You are allowed to move either right or downwards. The array is filled
with 1's and 0's. A 1 indicates that you can move through that cell, a
0 indica... |
I got asked at an interview to write a program that, given a NxM matrix with zeros and ones, prints out the list of clusters of 1s. The clusters are defined as patches of 1s connected horizontally, vertically or diagonally.
Here's the code I submitted but I'm wondering if there is a better way, e.g. a well-known algori... |
This is done in the style of a single class, that should work like any other io-based object in Python. Help is much appreciated with anything regarding performance, documentation, or anything else.
import io,win32file,win32pipe, win32api
import msvcrt as ms # for fd magic
class pipe(io.IOBase):
def __init__(self, ... |
I am looking for better ways to write this code. At the moment it grabs a list of all navigation items and places them into an array (using PDO).
However, as you can see, it is using two foreach loops to grab the subnavigation items under each parent. Is there a better way that this code can be written?
<ul id="nav">
... |
I wrote this little page to calculate the least weight and/or optimum gold amounts for DnD for 4th and 5th editions.
I think I've managed to refactor it to its best, but I have little experience with JavaScript so I would like a critical review of what I have done so far.
Public version to try
<html>
<head... |
This piece of Angular code is used to add/remove an item to a favourite array and display it on page load. Firstly I check if I have an array and then create one if not. It also checks the localStorage on page load.
How can this be improved?
$scope.favourites = $localStorage.favourites;
$scope.addExerciseToFavourites ... |
For the following question, the function
• should mutate the original list
• should NOT create any new lists
• should NOT return anything
Functions that do not create new lists are said to be ”in place.” Such functions are often desirable because they do not require extra memory to operate.
Define shift_left, a functi... |
The problem is :
The sequence of triangle numbers is generated by adding the natural numbers. So the 7th triangle number would be 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28. The first ten terms would be:
1, 3, 6, 10, 15, 21, 28, 36, 45, 55, ...
Let us list the factors of the first seven triangle numbers:
1: 1
3: 1,3
6: 1,2,3,6
10... |
I've written a ruby implementation for Sieve of Eratosthenes algorithm, however benchmarking it against the Ruby's Prime module I have still a far slower algorithm - and I am struggling to understand why.
require 'set'
def numbers_with_multiples_less_than n
(2...(Math.sqrt(n)).ceil)
end
def primes_till n
possible... |
I'm trying to implement my own API. This code excerpt should show the basic working routines. The storage is temporary an in-memory-array and the only HTTP method for now is POST.
I outsourced the parsing into ParseRecordRequest(), because I use the code twice for POST and PUT requests and will extend it with further c... |
I'm trying it out just to see if I could solve it. It would be great if I could receive tips on how to improve it.
//input
var decimal = prompt("Please enter a decimal number");
if (decimal >= 1 && decimal < 1000000000) {
//convert to binary
var binConvert = parseInt(decimal, 10).toString(2);
//reverse bin... |
When sorting by multiple keys, I need the second key to alternate between standard and reverse sorting. This is to minimize the change in the second key. For example, if I have a list of dictionaries, I want the first sort (group key) to be sorted and then the second sort (sort key) to alternate. This should produce... |
I'm solving "mastermind game" problem from CIS haskell course. Here is the link to assignment pdf if someone is interested.
List of possible colors is defined like this:
data Peg = Red | Green | Blue | Yellow | Orange | Purple
deriving (Show, Eq, Ord)
type Code = [Peg]
colors :: [Peg]
colors = [Red, Green, Blue, Y... |
I'm adding some functionality to an existing library of data structures in Common Lisp, with a view to asking the original author if I can take over maintenance and development of it. While the original code is very well-organized, one of the features it didn't have was a way to iterate over the contents of a tree, suc... |
I am serializing and de-serializing a class object within the class which is then sent over the network like this:
class data
public name as string
public cmd as Commands
public message as String
Public Sub New(ByVal byteData As Byte())
Try
' convert byte array to memory stream
... |
This code gives me info of a movie and the movies directed/acted by corresponding director and actors. It is working as the way I expected but I included lots of try and except statements and as a result my code is slow. Is there anyway to speed this up?
from imdb import IMDb
def rating(name):
p1 = ia.get_movie(i... |
I started reading a Clean Code book and some other articles on the Internet about OOD and design patterns and I'm a little confused. I've started to code a little string to integer parser which currently parses a first integer in string larger than 0 or returns -1.
Could you look and give me some idea if this is writte... |
I've created a fairly simple word search generator/solver. I'm looking to improve on picking the right algorithm to tackle problems like this, so any criticisms on my code would be greatly appreciated :)
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<ctype.h>
#include<time.h> //for stop watch
#includ... |
I'm getting three inputs and based on those three inputs, I'm returning. Input items may vary, so I used CASE WHEN statements here.
Is this code correct? If so, how can I make it more optimized?
ALTER Procedure [dbo].[WP_GetAllItems]
@IsActive bit,
@OrderMode bit,
@OrderBy varchar(75)
as
Begin ... |
I don't have formal training in coding, so I would like some input in my code. It is working really well, without any issues. I just wanted to see if I can somehow improve my code. I divided the major things into separate function.
Here is a working demo.
(function($) {
// Use _ to template the resultsTemplating de... |
I have written the following code for my personal website, in Jade and Stylus. Can anyone review this code? Are there any tips that you can give me on how to make it better?
GitHub
main-page.jade:
doctype html
html(lang="en")
head
title Darcey Mckelvey
link(rel="stylesheet" href="/css/main.css")
body
he... |
This is something that I am proud of and would like to have people dissect and tell me where my faults are in. I feel that if I open my best for criticism then maybe it will reveal the deep seeded bad habits in my coding.
I know about the null format for the frame in the main class is not kosher. So, please skip over t... |
For the following question, the function
• should mutate the original list
• should NOT create any new lists
• should NOT return anything
Function that do not create new lists are said to be ”in place.” Such functions are often desirable because they do not require extra memory to operate.
Define "filter_mut", which t... |
.data
D0: .byte 0x04; first number
D1: .byte 0x03; second number
.bss
R0: .space 2;result
.txt
_main: ..
..
CALL mySUB
..
mySUB: ...
....
return
.end
Given above, write a program that would read the numbers (in D0 and D1) and call a subroutine, mySUB, that adds the t... |
Follow up of this question.
Things altered:
Put logging (debug level) for creating and starting thread.
A separate thread for starting the different threads.
Locking object and synchronise for starting the threadIncreaser.
Changed the while condition of the while loop of threadIncreaser so getting the size of the que... |
I'm currently writing a small asset tracking system.
The implementation should meet the following requirements:
The system; scans the transfers every 15 minutes. If the transfer is
accepted by the receiver by the specified transfer time, realizes the
transfer. When a transfer is realized, assets are assigned to th... |
I decided to write a sieving prime-finding programme and make it fast. It works correctly but counting the primes below 10**9 takes 36 times as primesieve downloaded from http://primesieve.org/.
Now I understand that they have a World Record so they better be fast, but we all know that a compiler is much better than a ... |
#ifndef ANY_H
#define ANY_H
#include <typeinfo>
namespace _notYourNp
{
struct BaseHolder
{
BaseHolder()
{}
virtual ~BaseHolder()
{}
virtual BaseHolder* clone() = 0;
};
template <class T>
struct Holder : BaseHolder
{
Holder(const T& type)
... |
I have an action that does two things:
It sends a chain of commands, and gets the response from an external API that we call wrapper.
It logs the chain of commands and the tunnel (look at tunnels as different machines) the command was sent to.
My problem is the contents of the if statement. The two things (sending th... |
I've written this and it works great. Is there any shorter or simpler way to achieve the same result without distinguish between cases?
Node* recursive_ordered_insert(Node* head, int val)
{
//special case: first elem is null
if (!head)
{
head = create_node(val);
return head;
}
//sp... |
EDIT: This question is followed up by this question.
I'm in the process of filtering some very(!) large files (100gb+): I can't download files with a lower granularity. This is a followup from this question.
The problem is as follows: I need to filter large files that look like the following (3b+ rows).
TIC, Date, Ti... |
One day, I was thinking:
Wouldn't it be nice to set a class and have all the styles defined?
And that is exactly what I did: a PHP file that generates CSS with pre-defined styles. So, for fun, I built the following:
<?php
if( @is_file($file = basename(__FILE__, '.css.php') . '-config.php' ) )
{
$conf... |
In honor of Star Wars day, I've put together this small Python program I'm calling JediScript. JediScript is essentially a scrapped-down version of BrainFuck without input or looping. Here are the commands in JediScript.
SlashWithSaber: Move forward on the tape.
ParryBladeWithSaber: Move backward on the tape.
StabWith... |
I am saving (image) files to PostgreSQL database in my Node.js and Express server application. The code is used to upload user images to server (at the moment it is not restricted to image files in any way though, but that's not the point). The files are sent as multipart requests and they are parsed using Busboy. Thes... |
I'm building a program to scrape data about hockey games in order to compile statistics. One of the run modes will process all of the games in a single season (1230). Processing a single game consists of scraping, parsing, calculating and persisting gathered data and needs to be performed synchronously, but multiple ga... |
My function is supposed to go through a given List<Integer> and find integers of same value, but only count them if the integers between them is <= the the integers that are equal:
public static int findPairs(List<Integer> arr) {
int total = 0;
for(int i = 0; i < arr.size(); i++) {
for(int ... |
To give a little context before showing the problem:
I am creating a RESTful web application. A User can have multiple addresses, emails, phones and projects. Each of these is represented similar to the following object model, (Address in this case).
public class Address {
String type; //home or work etc.
Strin... |
Is it reasonable to mix Control.Lens operations with the ones provided by the "standard library"?
Consider the following fragment using qualified Data.Map as Map:
getUniqueIdent :: String -> State (Map.Map String Int) (Maybe String)
getUniqueIdent typeName = do indices <- StM.get
let identi... |
I'm just hoping if there's a way to simplify this recursive code that takes 2 sorted lists and combines the two together in a sorted manner (without actually having to re-sort them).
def merge (l1,l2):
if len(l1) == 0 and len(l2) == 0:
return []
if len(l1) == 0:
return l2
if len(l2) == 0:
... |
3 string trimming functions:
Trim whitespace from the beginning of a string.
Trim whitespace from the end of a string.
Trim whitespace from both ends of a string.
Looking to improve code for:
Correctness (tested code - but so far no holes) - especially overlapping src/dest cases.
Design
Portability (3 tried: ... |
I'm looking for some general tips on code practices, doing things properly in idiomatic pythonic way. But mostly I want to know if this was build correctly. I tried making neural nets in the past, but failed horrible, but this one seems to be working fine.
The backpropagation method is still not developed because I sti... |
This code exists in my home repo and in general nobody else has really touched it. Living in such a vacuum has left me kind of uncertain of the actual code quality and correctness which is why I am approaching this site hopeful for a second set of eyes.
This is implemented and working, however what I am interested in i... |
I made a simple Question "system":
Answer
Stores an answer (string) and a boolean value to check if the answer is correct or not.
public class Answer {
private String answer;
private boolean isCorrect;
public Answer(String answer, boolean isCorrect) {
this.answer = answer;
this.isCorrect =... |
This is the first PHP script I have written. It downloads and installs a plugin called "anti-spam" by using the WordPress API. It also provides an option to either delete all comments or delete the comments, which are unapproved or marked as SPAM.
<html>
<head>
<title>SPAM tool</title>
<style>
f... |
I've written a Sudoku puzzle generator. It currently runs through each line of the 9x9 grid and places numbers randomly if they're valid. It loops over all the numbers from 1-9 and then if it finds itself trapped in a corner with no valid answers it throws out the whole board and restarts.
I tested it by making 1000 pu... |
I was said to post this as a new question. I improved my code from:
Little part of the string to integer parser vs Clean Code
However I think that it break SRP as it parses, iterates through string and checks if letters are numeric. Could someone involved in OOP say what does he think of it? I agree that wrapping Index... |
I have 5 different forms where I am disabling the submit button when a valid form is submitted so the form can only be submitted once. I am using a hidden field on each form to get the form Id.
function OnSubmit(buttonId) {
var disableButton = false;
if ($('#formType').val() == 1) {
if ($('#CreateEntityName').val(... |
This code asks the user to enter a message containing the lower case characters a-z, it then encrypts it into a Vigenere Cipher and also decrypts the cipher to prove the reverse lookup works.
package com.testing;
import java.util.Scanner;
/**
* A Vigenere Square or Vigenere table consists of the alphabet written out... |
An error in a live environment was detected when trying to convert string geo coordinates into a double.
The current culture (hu-HU) uses comma instead of point for the decimals and that produced an exception when trying to parse Double.Parse(47,545874)
That's why I'm using CultureInfo.InvariantCulture and the reason ... |
The following function appends a tuple to two Maybe [a]'s.
tupleToMaybeList :: (a, a) -> Maybe [a] -> Maybe [a] -> Maybe [a]
tupleToMaybeList (a, b) cs ds = do
x <- return a
y <- return b
xs <- cs
ys <- ds
return ((x : y : xs) ++ ys)
Please critique it for idiomatic Haskell-ness.
|
Is the algorithm correct? It seems to work.
print("Multiple sequence longest common subsequence implementation in Python.\nFor example a naive algorithm would perfom c*128^128 elementary operations on a problem set of 128 sequences of length 128 elements.")
print(" That is: ", 128**128, "operations.")
from collections... |
I'm learning about Gauss-Jordan Elimination, and decided to write a program to automate the process to help solidify my understanding. Along with the algorithm itself, I wrote a Matrix class that has methods for the 2 required row operations (Adding a row to a row, and multiplying a row by a constant). My main concerns... |
I'm in the process of filtering some very(!) large files (100gb+): I can't download files with a lower granularity. This is a followup from this question.
The problem is as follows: I need to filter large files that look like the following (3b+ rows).
TIC, Date, Time, Bid, Offer
AAPL, 20090901, 09:45, 145, 145.5
AAP... |
I need to append some query parameters to my API URL. The consumer of my API would pass me this optional structure called as APIParameters, which contain 5 optionals, one array of strings and rest strings
Lets assume the following:
let baseURL = "baseURL"
let path = "path"
This is the final URL structure
//assuming s... |
I feel I have overcomplicated the process. What can I do to improve the following code?
ids = []
File.open(filePath, "r").each_line do |line|
i += 1
parts = line.split(',')
parts[1] = parts[1].to_i
parts[2] = parts[2].to_i
# If the id doesn't exist in our ids array then create it and add the
# second id... |
I have written the following script that is pointed at a CSV through it's file name and then splits the file into "drops" (for mailings) and does a couple of operations on it. As of now it works, but seems fairly slow when I use it on any significant number of records (>5000). Also there is a section in there where I n... |
public class ArrayUtil {
/**
* Field INPUT_LESS_THAN_TWO. (value is 2)
*/
private static final int INPUT_LESS_THAN_TWO = 2;
/**
* Method removeDuplicateElement. Given a sorted array of integers, this
* method removes the duplicate elements. Input array is sorted array and
* can ha... |
I know that I'm not suppose to alter a Set as I iterate through it. But, in the deleteRow(String counter, String reading) method below, doing just that will make the code much more readable and clean.
Because there is so little going on in each iteration:
Is there risk?
Would a respectable coder look at that and c... |
This is a probe request packet sniffer using python/scapy. It sniffs Dot11ProbeReq packets and display the ssid, MAC of device and manufacturer name from the probe requests. Can also output the data to a log file if desired. Right now I feel the script is a bit slow and I can see it slow down from the first time I wrot... |
The following code is from a utility I've written for myself.
It takes a file in this format:
[SOME_CODE]
Some following text
[SOME_OTHER_CODE]
Some following multi-line
text
And then outputs a C header file containing some #defines with the strings encoded.
The bottom function, convert, is the one I'm scratchi... |
Here's an implementation of a class which is similar to std::map, but it's not a complete/identical implementation.
I know C pretty well, but am a beginner with C++, so it took me some time to figure out a couple of things, e.g. how to implement an iterator. For now, the iterator only goes forward, because I didn't fig... |
For a bioinformatic problem, I found myself wanting to create a list of strings within Hamming distance "k" of a reference sequence. I wanted to do so quickly and pythonically. I've implemented it in pure python and in cython, with and without type declarations. The time performance has been identical. (I also compared... |
Title says it all. I'm basically initializing a two-dimensional array and changing the fields one at a time.
It might be a good idea to do this OO.
A Grid class seems right, perhaps as a subclass of Array. So far I haven't been able to successfully port it. Pointers would probably be a good idea as well.
Note this is k... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.