instruction stringlengths 71 71.9k |
|---|
I have implemented a CSV reader. I think I did pretty well. Since CSV is a loosely defined format to begin with I decided to allow some malformations, like anything but a delimiter after an enclosed value.
Maybe someone could point out improvements to this class, I would be happy to know them.
using System;
using Syste... |
I'm new to Ruby, but not to programming. I just need a simple script that, given a text file, will pull out around 10% of the lines at random. Below is what I came up with based upon a Python script I wrote. What do I need to do differently to make it more Ruby-like?
prng = Random.new
File.open('english-words-parti... |
The point of the script below is to read in the 10th column which is the total number of minutes a runner took to finish the marathon and convert it into form of "hours:minutes:seconds". Is there a better way?
require 'csv'
File.open('bostonmarathon-2012-results.txt', 'w') { |f|
skip = true
CSV.foreach("bostonm... |
This is a very simple for loop, but I find it very, complex-looking. I hope you can give me some insight on how it may be improved.
int Tindex = 0;
int16_t Test[960];
int TestSize = SampleSize / 2; //Test is 16Bit, Half size of 32bit
int TestChannels = 2; //Stereo
float copy = 0; //Used to store Audio data used to Mix... |
I came up with this function rangedReplace as an exercice to use recursion and try different ways to make it work (I made at least 3 completely different versions). I think this version is the best but I have a feeling I can improve the way the functions/arguments are handled especially in the censor and in the main fu... |
I'm trying to write the most efficient query I can to pull the relevant data I need for retrieving the latest conversations for a user, ordering groupings of conversations by most recent message in that conversation.
I don't like the idea of using a subselect to match the max timestamp. Is there a better or more effici... |
I have a WCF service in which I am reading and adding some records to a .xml file. I load the .xml document in the constructor and use it in all the methods and save when it's updated.
I want to know if this is the correct way of using it. I have seen code around where people load the xDocument only when it's require... |
Given a Binary Search Tree (where all nodes on the left child branch are less than the node), and all nodes to the right are greater/equal to the node), transform it into a Greater Sum Tree where each node contains sum of it together with all nodes greater than that node. Example diagram is here:
Looking for code revi... |
$roleId = pg_escape_string($_POST['role']);
$grantValue = pg_escape_string($_POST['grant']);
$feature = pg_escape_string($_POST['feature']);
$permission = pg_escape_string($_POST['permission']);
$permissionsModel = new Permissions();
$record = $permissionsModel->getPermission($roleId);
//assemble ob... |
If I have to loop results of a query echoing first all fields of a column, then echoing something not to loop, then fields of another column.
<?php
$con = mysqli_connect();
echo 'Latest users who tried our test<br>';
//select the fields of the first column
$query1 = mysqli_query($con,"SELECT user FROM ris_uinversita LI... |
I've written some jQuery code that works, but I'm a novice in jQuery and I want to know how to improve my code if possible.
I know I have 3 near identical blocks of code. If I create a function, the code will be the same. I'm looking for more accurate code and am trying to reduce my code into fewer lines.
JSFiddle
... |
I have written some jQuery which validates a group of drop downs. It checks the text value selected in all the drop downs (first three characters), and if there is a duplicate, it warns the user.
This code seems quite messy, I was wondering if anyone would like to attempt to refactor this. Tips for improvement are we... |
Why this plugin:
I am developing a mobile app - at some point, I felt like this would be a good idea to give the users the possibility to control everything in the app with touch gestures, hence the need for a plugin able to recognize more than the basic swipe events.
What it does:
When the user starts touching the scr... |
I have very quickly mocked this up as an example model in Angular JS:
.factory('car', function() {
function car(serial, name, type, manufacturer)
//intended to be private
var serial = serial;
var name = name;
var type = type;
var manufacturer = manufacturer;
this.getSerial = function() {
... |
I am doing a date validation. I have no. of pages, which have the date field. User can input the date like "220875" or "22AUG75" - I need to test both and check the length as well.
function isValidDate(newDate) {
newDate[1] = newDate[1]-1;
newDate[2] = (parseInt(newDate[2]) < 50) ? 2000 + parseInt(newDate[2]) ... |
I've written an asynchronous retry method as an answer for this question. I'd like to get your opinion of the implementation and whether there are better ways to implement this. You could also implement this with async-await but I thought this would be a more efficient implementation.
public static Task RetryAsync(Func... |
With Tornado 3.2 they made some updates to auth module and have updated the code. Earlier I was using open id for Google login, since it will be deprecated in the future I am switching the code to Oauth 2.0 login. Also I was using tornado.web.asynchronous, now I have updated the code to use tornado.gen.coroutine
/produ... |
This function adds a number of hours to a 24 hour clock:
/**
* @param {Integer} now The current hours
* @param {Integer} add The number of hours to add
*/
function addHours(now, add){
var h = (now + add) % 24;
return h < 0 ? 24 + h : h;
};
addHours(2, 5) //7
addHours(23, 5) //4
addHours(23, -5) //18
addHo... |
Here is simple repository pattern that I use to access data in my database. I would like some advice on how to improve this code. Commenting on my code quality is also welcome too!
public static class ProdRepository
{
private static Entities context = null;
public static Entities Context
{
get
... |
I am kind of new to programming. Picked up some Perl about a year ago and now learning some Python. I am pretty confident in Perl, but Python seems un-natural to me.
I wrote a little script that parses log files and indexes them into Solr in JSON. This is for some reporting.
I wanted to see if there are more pythoni... |
I built a very basic image slider, but I'm still having trouble refactoring.
I caught myself reusing same code for clicking the previous/next buttons, selecting a slider dot, and the automated sliding. The difference between these actions is how the index of images changes. I'm not sure how to break out that piece o... |
I'm an upstart, been only professionally programming for a bit less than 2 years, mainly in Java as I am currently working as an Android developer.
I often find myself thinking about how to improve the readability and maintainability of my code, and establish some style guidelines, for the project that I am working on,... |
I wrote an algorithm which should cut a companies name into 3 strings.
Input: 1 String
Output: 3 String.
Conditions:
String 1 2 and 3 shall not be longer then 35 signs. If the Input string is longer then it should be cut to a length of 105.
If you have fun and be interested in algorithms it would be nice if you take ... |
I cannot edit the QueryPermissions class because it is an external .dll that was given to me to use. Yes, I realize it's a bad practice to use an out variables, but I am pushing for a rewrite of that service.
As you can see below the two methods do the almost the EXACT same thing only one uses a groupkey and the other ... |
I have set up a Dictionary that calls on a class to fill a DataGridView via SQL statements. The problem is in two (out of 5) instances the value passed HAS to be an integer, but the value comes from a textbox so it is being passed as string. Before I set these Dictionaries up I was just using a switch statement that ... |
We have a base interface:
public interface IMessage
{
//Some properties
}
then we have derived messages that implement this interface such as:
public class AlarmEventMessage: IMessage
{ //Some properties }
Now, these messages get routed to a message handler tha... |
I am trying to find if a subwebsite exists in sharepoint, and if it does, then add +1.
I think the loop can be improved.
// subsiteName will be like "FruitCrateOfCompanyX"
public static string FormatMyHomieURL(string subsiteName, string mainSite)
{
if (!mainSite.EndsWith("/"))
mainSite = mainSite + "/";
... |
I've replaced the following horrendous Excel formula (values and names have been replaced):
=IF(AND(SourceTable[@Field1]="Value1",SourceTable[@Field2]="Value2"),"Result1",
IF(SourceTable[@Field2]="Value3","Result2",
IF(AND(SourceTable[@Field1]="Value4",SourceTable[@Field3]="Value5"),"Result3",
I... |
I have a working SQL statement which shows the following:
Player
Champion
Role
Total Kill/Death Ratio
Total Kill+Assist/Death Ratio
Total Win %
Difference between Ratio from one month ago
Difference between KA Ratio from one month ago
Difference between win % from one month ago
However, I don't think it's quite as op... |
I have a function that takes a Dictionary<String, Object> as an argument. It uses this Dictionary to create parameters for a query string.
private static TableAdapters dataSource = new TableAdapters();
private void findScriptsQueryButton_Click(object sender, EventArgs e)
{
string fillBy = findByComboBox.SelectedItem... |
This is the successor of my previous CSV reader. I implemented quite some useful suggestions.
I will give explanation on a few parts:
Prefixing constant identifiers with Sym_ (abbreviation for symbol) is a practice I learned from writing parsers for more complex formats. Such formats contain alot more symbols than jus... |
I read effective Java by Joshua Bloch. And it said use enums over int constant. So I was thinking instead of using hard coded strings I could also use enums. The forgotpassword.txt and confirmation.txt are plain text resource files.
When the class is loaded, I get the contents of the text file and store it inside of a ... |
I'm new to ui.router in Angular and have to build an app, which contains a header, sidebar (off-canvas), feedback area (save successful and warnings area) and a content area.
I thought it would be best if I split up all things and create different (nested) ui-views:
index.html
<div ui-view="head">loading...</div>
<div ... |
Given a linked list and two integers M and N. Traverse the linked list
such that you retain M nodes then delete next N nodes, continue the
same until end of the linked list.
Input:
M = 2, N = 2
Linked List: 1->2->3->4->5->6->7->8
Output:
Linked List: 1->2->5->6
I'm looking for code review, optimizations and b... |
I'm having trouble figuring out the best approach with DI. After doing more research, Mark Seeman recommends using the Composition Root approach. In my example, I am using XML configuration to design my mappings which allows me to drop any new dll that implements an interface without having to perform a build on the wh... |
I have a class that implements Queue and draws values from other queues which may still be referenced outwith it. I want my method to draw values from the contained queues, using synchronized locks on them to ensure thread safety with other code that uses synchronized locks on the queues.
The way I've tried to achieve ... |
I have a script that is standardizing a large amount of data in the database. The standardization involves applying over 500 regular expressions to the data.
Here is some quick pseudocode:
Load the records from the database
for each record
for each regular expression ##predefined list of 500 regular expressions
... |
This Connect 4 game will be used for implementing game-playing AI. Sample players are supplied. One takes user input, and the other plays randomly. Right now it's set for a human player to play against a randomly playing agent, but in the future I plan to try out algorithms such as Minimax and have AI agents play again... |
Given two arrays A and B, of length N and length k respectively, if we move B over A and take the sum of product of corresponding elements of A and B, then find the minimum of those sum of products.
For example, if A=[2,3,4,5] and B=[1,3], then after moving B over A, we get 3 possible values [2*1+3*3, 3*1+4*3, 4*1+3*... |
As a small exercise I have written some string formatting and printing functions in C++11. I would like a bit of code review, not so much on the merits of using this over something like std::stringstream or boost::format, but simply whether or not my implementation makes sense. I realize that simply performing string r... |
I have two identical objects on the page, so I get more of the same lines of code. Can anything be made simpler, perhaps with merging?
for(var i=0;i<ticks.length,i<ticks2.length;i++) {
var tick = ticks[i];
var tick2 = ticks2[i];
var tickCenter = tick.offsetWidth / 2
var offset = (i - currentTick) * pixelsPerT... |
I decided to setup a generic makefile to compile SFML programs, as I'm going to be making a bunch of small apps over the next few weeks playing around with it. I'm still new to writing makefiles (still weaning off of using IDEs), but I'm pretty happy with how it turned out.
#############################################... |
[TestCase(new[] { 1, 2 }, 1, Result = 2)]
[TestCase(new[] { 1, 2 }, 2, Result = 1)]
[TestCase(new[] { 1, 2, 3 }, 2, Result = 2)]
[TestCase(new[] { 1, 2, 3, 4 }, 2, Result = 2)]
[TestCase(new[] { 1, 2, 3, 4 }, 10, Result = 1)]
public int TotalPageCountIsAccurate(int[] testSequence, int pageSize)
{
var pagedList = ne... |
The following code works but is a mess. But being totally new to Ruby I have had big problems trying to refactor it into something resembling clean OOP code. Could you help with this and explain what you are doing?
require 'nokogiri'
require 'open-uri'
require_relative 'db.rb' # Not used
require 'mechanize'
requ... |
I have two tables in the database:
Credentials (userid, password, usertype)
Customer (customername, userid(foreign key))
I need to validate username,password and usertype and create a session variable for customername.
I have organized the code and it works fine, but how can I minimize the code and make it efficient?... |
I decided to port my favorite unit testing framework, Catch, to JavaScript. So far I'm focusing on test cases and sections. I'll add assertions in phase 2, and output in phase 3.
The goal for this phase was to get all the assertions in the following test code to pass:
function assert(value, message) {
console.log(v... |
I've started writing a piece of code to help me search for an object in all the objects found in the diagonals of an M x M 2D array.
Though the code works, I'd like to know if there is a way I can improve on it or there exists a different technique I could use to achieve the same result with fewer lines of code. I jus... |
Note
Please review the new question and ignore the following.
Overview
HTML Editor is an online HTML editor with a minimalist approach. Edit your HTML, CSS, and JavaScript code and monitor the instant live preview. It can also create, open and edit other types of text files such as .txt, .css, .js, .svg, etc.
Please r... |
Recently I have been learning Python programming, for about a week. I have covered all basic stuff - loops, strings, input masks - and have challenged myself by making a little game. It isn't much, that I know, but I was just wandering whether or not I have done everything correctly.
Any feedback regarding functions an... |
This question is a cross between career question and a code review. I was uncertain where to ask, but since there is code involved I went with CodeReview.
I’m going through the process of technical interviews, and it hasn’t been a positive experience but I’m trying to make sense of the feedback I’ve gotten to improve t... |
I created this library just for fun. Since I was a bit tired to write 10 lines of code to execute a simple select query in Android, I created a way make it simple.
It's not so advanced and some Android query features are not ported, such as beginTransaction.
BananaQuery is the main class which should be used to create... |
Out of a challenge for myself, I created this little program in which you can create "variables", test those "variable" values, test regular values, or clear all the "variables".
from operator import *
oper = {
"==": eq,
">": gt,
"<": lt,
"<=": le,
">=": ge,
"!=": one,}
var = []
def println(s... |
I started a project to build my own invoicing and management system to take the place of prohibitively expensive QuickBooks software. This will be broken down in 5 steps, with the current step in bold font, and previous steps linked.
Design the DB schema and table relationships, and insert data for standards tables
C... |
I am currently doing a project for school, and I am completely stumped. We are only on Chapter 8 of C# Development 1 and I have a question about the code.
The project is:
Use a one-dimensional array to solve the following problem:
Write an app that the user inputs numbers, each of which is between 10 and 100, inclusiv... |
I want to check if the structure that I use contains an object. To do so I wrote the following contains method:
boolean contains(Topic t){
if (t == null)
return false;
if (t.equals(root))
return true;
else
return false;
}
Is this a good way of writing? Is... |
All I want is a simple "yes/possible" or "no/and that's bad coding".
I have a card game I'm making and looking through your discard pile is a big part of it, so it's going to be constantly growing.
Can I make a for loop to create new touch event so I don't have to make an if statement for every new card in the discard ... |
So, whether you're still in the development stages or your app is already on the app store, you always hope your app isn't crashing. But if it is, you want to be sure you've got good crash reports, right? Moreover, if your app is on the appstore, it may not be sufficient to wait around for Apple to upload crash repor... |
Is my Application.php class secure for continuing development?
The Application.php acts as a registry for the whole application. I tried not to rewrite already working code that is being pulled from Zend Framework and PhalconPHP, but allow myself to have freedom with using frameworks within my web application.
Also, pl... |
How can I improve this method that adds data to three tables in the database?
The tables are:
UserTable
UserInfoTable
ContactTable
UserInfoTable and ContactTable have a one-to-many relationship, with ContactTable having UserInfoID as a foreign key.
public static boolean addUser(User user) {
Connection connection = ge... |
I have one complex method with 1890 paths. I don't know how can be this refactored. Can somebody add some tips about it? Maybe the MySQL table structure is wrong.
public function fetchClubChallengeState()
{
$c = $this->caller->in_club;
$o = $this->opponent->in_club;
if (!$c || !$o) {
return false... |
I have a huge list of song objects in my program and I need those objects in almost all activities. Well, at least a part of it up to everything.
So I created a class which looks pretty much like this :
class DataStore {
private static ArrayList<Song> songList;
private static ArrayList<Album> albumList;
priv... |
I want to implement KD tree. I have defined class Node as follows:
public static class Node{
int id;
public double x;
public double y;
public Node leftChild;
public Node rightChild;
Node(int id, double x, double y){
this.id = id;
this.x = x;
this.y = y;
leftChild... |
I have class point that represents point in 2D and I want to sort these points once based on their x-coordinate and second based on their y coordinate. Since x and y are double values my code looks like this:
public static class Point{
int id;
public double x;
public double y;
Point(int id, double x, do... |
I wrote this implementation using templates. It works fine and as expected. Just want to know if this can be improved. I have some specific questions too at the end. Please feel free to critique to your heart's content.
#include <iostream>
template <class T>
class Tree
{
// Internal class which stores only Node re... |
I study data structures on coursera's course, and there is an extra exercise to create a Queue data structure.
I created it:
class Queue {
Integer[] data;
int head, tail;
public Queue() {
data = new Integer[2];
head = 0;
tail = 0;
}
public int size() {
return tail - head;
}
public bool... |
I have a script which dynamically loads data onto a restaurant menu for printing. Could the following code could be shortened at all?
<script>
$(document).ready(function(){
$('#prestarters').load('prestarters.php', '', function(response, status, xhr) {
if (status == ... |
I want to construct KD-Tree from unsorted List of points in the plane (i.e. 2-KD-Tree). To do so I used the method from Wikipedia: http://en.wikipedia.org/wiki/Kd-tree#Construction This is my code:
public static Node buildKDTree(List<Node> list, boolean depth){
if(depth){
Collections.sort(list, Node.xCompa... |
Just used DI containers in MVC projects, via constructor injection, and I'd need to now inject a service into a console app. I'm using Autofac so I followed what I found here.
The code would be something like this:
The service the console app depends on:
public interface IBatchService
{
void WriteInformation(string... |
I have a node.js/express.js based REST application. In one GET service I am querying data based on different set of request parameters. I am looking for a better way to implement it.
function handleGet(connection,req,res) {
var sql = 'SELECT id, name, age, rent, marks FROM student WHERE class = 10';
if (req.param('mi... |
I wrote these methods to encode data as array of TLV objects, and also to serialize and deserialize them. Any feedback on improvements, etc. would be appreciated.
Please note that I ignored endianness issues so far, as they are not relevant for me.
Also I am using fixed size array for TLV objects which should be fine f... |
In following query I'm use both Common Table Expression and Outer queries. Apparently both looks same to me.
If I summarize my requirement, I have employees in SalaryTrans table and I want to find out amounts to be recovered from their salaries monthly. Table Rcovery contains all recovery data. Table Instalment contai... |
I've been implementing a function for calculating the nth Fibonacci number in F#. So far the best implementation I could come up with is this:
let fib n =
let rec fib =
function
| 0 -> 0I, 1I
| n ->
let f1, f2 = fib (n / 2)
let f1' = f1 * (2I * f2 - f1)
l... |
I wrote the following short test code to test the performance of C++AMP and the PPL libraries against the sequential STL implementation of std::transform. To my surprise, both C++AMP and PPL implementations were significantly worse than the sequential implementation (C++AMP: 128ms, PPL: 51ms, Sequential: 25ms). This pa... |
This post is in reference to: Parsing Solr log files
I re-wrote most of the code and split it up into a couple of classes. Currently, the class functionality is pretty limited, but I can see that I would need to reuse that functionality elsewhere and I plan to build them up a bit over time.
Let me know what you think.... |
I wanted to practice using sockets and multithreading. This is simple code where I start a Server and connect to it via Client and chat between them.
Server class:
public class Server {
public static void main(String[] args) throws Exception{
ServerSocket serverSocket = new ServerSocket(4545);
Socke... |
This is my first attempt at splitting the download buffer into several threads by the number provided. I want to improve on performance and better implementation approach.
import os
import requests
import threading
import urllib2
import time
url = "http://www.nasa.gov/images/content/607800main_kepler1200_1600-1200.jp... |
I'm trying to get a better understanding of decoupling methods. Right now, I have this method:
private bool ContainsLegalFirstName(DataRow row, string legalFirstNameColumn)
{
return row.Table.Columns.Contains(legalFirstNameColumn)
&& !String.IsNullOrEmpty(row[legalFirstNameColumn].ToString());
}
I was thin... |
I feel like this maybe to much for one method... This method lives inside of a service class which is called by an interface. It dumps data into three different tables within a database.
public UserAccount CreateAccount(NewAccount newAccount)
{
if (!AccountAlreadyExists(newAccount.UserName))
{
string salt = St... |
In my application I need to search for some songs on my external storage card every now and then. On startup I read everything, however when it comes to new activities I thought I could just pass the file paths and read the songs I need again.
I've created this function:
public static Song getSong(Context c, String son... |
I have a Visual Studio Solution which has a bunch of Projects in it. One of these projects is called "Services" and is basically the junction point between all remaining projects. When I built it originally I made it as generic as possible so I can expand on it. At the time I only had to work with Entity Framework back... |
I have an image upload script that uploads images to the server:
<?php
define("UPLOAD_DIR", "uploads/");
$fileType = exif_imagetype($_FILES["myFile"]["tmp_name"]);
$allowed = array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG);
if (!in_array($fileType, $allowed)) {
header('Location: edit.php');
exit();
}
if ... |
I am writing a utility method which can check for empty and null string, or collection or an object or any general types -
public static boolean isEmpty(Object obj) {
if (obj == null)
return true;
if (obj instanceof Collection)
return ((Collection<?>) obj).size() == 0;
// is below line expe... |
Find all nodes, which are at a distance of k from the input node.
http://d2o58evtke57tz.cloudfront.net/wp-content/uploads/BinaryTree4.png
Input:
target = pointer to node with data 8.
root = pointer to node with data 20.
k = 2.
Output:
10 14 22
Looking for code-review, optimizations and the best practices.
Note: This... |
I wrote a user authentication program(s) for an MVC application. Before you ask part of the project specs are I have to store user information in company databases on servers that aren't the web server so the default membership classes are out of the question (as far as I am aware membership creates its own database). ... |
Continued from phase 1; please read it first for background.
Overview
This phase focuses on assertions. Here's where things get ugly. Catch uses macro expansions to decompose assertion expressions. Since we don't have that luxury in JavaScript without adding a build-time requirement, we have to settle for Function.p... |
I've authored a couple of plugins which show popovers on a given element. One of the objectives for both was no specification of plugin direction. So instead of the implementing dev having to specify direction: left the direction would automatically gravitate towards the center of the page while staying "attached" to t... |
I've implemented a binary heap in F#. It's pure and uses zippers for tree modification.
To test it out I have implemented heap sort using it but it takes 10 seconds to sort a list of 100 000. Regular List.sort is instant and since heap sort should have the same complexity I'm wondering what I can do to improve my imple... |
I have some code that calculates the "sentiment" of a Tweet.
The task starts with an AFINN file, that is a tab-separated list of around 2500 key-value pairs. I read this into a dict using the following function:
csv.register_dialect('tsv', delimiter='\t')
def processSentiments(file):
with open(file) as sentiments:... |
import sys
x=int(sys.stdin.readline())
lst = [int(sys.stdin.readline()) for i in xrange(x)]
lst.sort()
print lst
How can I make this code faster for large input?
|
I want to make a menu-item which:
Reveals a drop-down submenu, when the item is hovered (using a mouse) or touched (using a touch-screen).
Lets you click on a link in the submenu, while the submenu is visible
Closes the submenu (without clicking on a link), if you move the mouse outside the submenu (using a mouse) or ... |
I have to solve the following problem: Given an array of integers and given an integer value, list all possible numbers frm the array that sums up to the given value.
Example:
Input: array = {1, 2, 2, 3, 4, 5}, int N = 5
Output: {1, 2, 2}, {1, 4}, {5} {2, 3}.
This is my solution:
import java.util.ArrayList;
public cla... |
Is it possible to rewrite this piece of code any better when it comes to efficiency and/or readability?
public function dispatch()
{
$key = array_search($this->reqUri, $this->routes);
if ($key !== false) {
if (isset($this->methods[$key])) {
if ($this->methods[$key] === $this->reqMethod) {
... |
The parser below is not designed for every single US address. I am parsing through a file where each line may or may not be an address. I am more focused on speed rather than robustness.
state-abbreviation-lookup and street-suffix-lookup are booth used for consistency (addresses will always be "ST" instead of "STREE... |
I'm using Python to find fixed points of a given function and then draw a cobweb plot to visualize it. Thanks to this question, I have the core of the code written and can accomplish the task, but I have a number of questions about improving the functionality of the code.
import numpy as np
import matplotlib.pyplot as ... |
I use Lazarus 1.2.4 and Freepascal 2.6.4.
I have created a program that reads a disk in buffers of 64Kb (tried various buffer sizes) using a repeat...until loop. Each buffer is hashed using the SHA1 unit, specifically, SHA1Init, SHA1Update and SHA1Final.
The trouble is, is that although it works and the hashes always ... |
Working on Functionally Solving Problems from Learn You a Haskell, I worked on the "Heahtrow to London" shortest path problem.
I'm working on a reduced set of this problem in order to solve a simple problem first.
It's a shortest path problem for the following map:
The rule is: you start a A or B, and then choose acro... |
A node has a next and down pointer. Merge the linked-list such that end result is sorted.
Here we have a top level linked-list, followed by a down-list.
If { 10 : {20, 30} , 35 { 40, 50 } } is the input data structure. It means that,
10 is connected to 35, using the next pointer. 10 is connected to 20 and 20 to 30 us... |
Douglas Hofstadter's Pulitzer-prize-winning book, Gödel, Escher, Bach, poses the following mathematical puzzle:
Pick a positive integer n as the start.
If n is even, divide it by 2.
If n is odd, multiply it by 3 and add 1.
Continue this process until n is 1.
The number n will travel up and down but eventually end at... |
I ran it and it's working, but I just want someone to double check that I followed the directions. Any suggestions or corrections will be appreciated.
Assume you have a NSString *str object containing some text. Write a code fragment to create a new string with all substrings "aaa" deleted.
My answer:
NSString *str... |
I am seeking advice on the efficiency and long term implications of various ways of capturing modifications to instance variables that I have tried implementing. Essentially, this is setup:
In my framework, I originally had a class whose sub classes were only supposed to contain public instance variables - kind of lik... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.