instruction
stringlengths
71
39k
I realize this won't stop people who know what they're doing, just a project I decided to undertake while I'm trying to learn Python and Tkinter. Would love some input! import Tkinter import base64 class crypt_mod(Tkinter.Tk): def __init__(self, parent): Tkinter.Tk.__init__(self, parent) self.paren...
I wrote two functions to return point coordinates spanning the n-dimensional hypercubic lattice of half size K (meaning that the coordinates along each axis go from -K,.. 0.. K). The n-dimensional cube volume should have (2*K+1)**N grid points. The functionality is split across two functions: one for returning the grid...
I have the following method which I use in multiple places, but it only differs by a few different things, so I was wondering how I can refactor it so I can have it in a common class and call it from there everywhere. public override DataTable GetRecords(QueryContext queryContext, out int totalRecords) { // Build Q...
I am working on Project Euler problem 37 and I have the following program: #!/usr/bin/ruby -w require 'prime' h=11 y=0 x=0 while x < 11 if h.prime? == true boo = true f=0 n=h c=0 while n > 0 f += (n%10) * 10**(10-c) n/=10 b...
The application is a student administration system using a .csv file for persistence as part of our school project. This is my first created a basic DAO. I'd like to have some feedback about what could be improved until now and how I could write good unit tests for the UserDAO.class. UserDAO.java package com.studenten...
I have a Clock class who inherites from pyglet.clock.Clock and behaves like a Singleton. Into the constructor method I have the following line: pyglet.clock.set_default(self) Who changes the state of the default clock of pyglet, setting my Clock object as the default clock. The constructor method leaves the Clock obje...
I am trying to teach myself a new language in three weeks. Can you please give me some advice on how to clean my code and make it faster or more reliable? This works fine. I don't "need" any 'free' code, I need the knowledge of what I am doing wrong, and what I am doing right so I can learn. Using sqlCon = New SqlCo...
I'm in the process of cross-training myself from CFML to PHP as part of a learning exercise. I'm learning from the docs and online tutorials and googling. As an initial exercise, I've knocked together the following PHP facsimile of some CFML code I have. I have a blog article explaining the requirement for the code. Th...
I made simple JavaScript xor function. It accepts string, numeric array and mixed array (char, string, num) as params. It returns string or an array. Returning an array is a must!. All numbers are printable on screen and there is no potential loss of information. String works excellent if you pass it in a variable. B...
This code generally works exactly as it is supposed to. I'm learning bash I'm looking for some constructive help that could help me improve my work. #!/bin/bash usage() { echo "Program for uncompressing tar, gzip, rar archives" echo "Allowed parametres: --help, --file, --input, --directory" echo "Exampl...
I'm making a function that takes the date a page was last edited, accessed through MediaWiki's API, compares it to the current date, and returns how long ago the page was edited, e.g. 1 year/2 days/etc. It's essentially a massive if/else statement, and I was wondering if there was a better way to implement it. var time...
I'm working on my Scala chops and implemented a small graph API to track vertices and edges added to graph. I have basic GraphLike Trait, and have an Undirected Graph class ( UnDiGraph) and a Directed graph class (DiGraph ) that extend the GraphLike trait. Here is some of the listing: trait GraphLike[T] { val verti...
I'm trying to validate email addresses as being from certain universities. I have a table, University, which is full of university domains. University email addresses often have different subdomains, and I want to be able to tolerate any subdomain under the domains in my table. I think the following works, but is poorl...
I am learning to program in R and to do that and create something useful in the process, I have decided to rewrite this Java applet for repeated measures simulation and to implement some new functionality. I have succeeded, but the code seems to run very slowly (5K simulations in around 8 seconds as opposed to ~ 0.8 se...
The purpose of this code is important, so here's a quick rundown. This code runs controls a physical machine which utilizes a camera and a moving stage holding an object to be imaged. Imaging can be broken down into two parts; exposing (collecting photons) and readout (reading the formatted image from the camera over ...
I have written a binary search algorithm, but it seems to be a bit different than other peoples that I've seen. I was hoping that the community could give me some feedback as to whether or not I'm missing something, or doing something the wrong way. Binary Search: import java.util.Arrays; public class BinarySearch ...
I've finally decided to design a class for this program, but some of the code still looks messy. I'm also a bit concerned about DRY, particularly in binaryToOctalHex(). The program is looking better, but I'm still not liking what I'm doing in the aforementioned function. I don't mind refactoring that if necessary. W...
I'm writing a function to append 5-10 bytes (count is random) at the beginning of a byte array, and 5-10 random bytes at the end: func padWithRandomBytes(b []byte) []byte { startBytes := make([]byte, 10-rand.Intn(5)) endBytes := make([]byte, 10-rand.Intn(5)) newSlice := make([]byte, len(startBytes)+len(b)+l...
I've just started learning assembly yesterday, and the first useful thing I've written is a clearmem function. I'm looking for general feedback regarding my coding of this function, whether there any flaws with it other than the obvious one of a user passing a value <= 0 to the size argument, or an invalid pointer to t...
I have just started learning Java, and don't want to start any bad habits, so please review my latest game code: import java.util.Random; import java.util.Scanner; class GuessMyNumber { public static void main(String args[]) { Random random = new Random(); Scanner input = new Scanner(System.in); ...
I'm working on a CMS system. The basis is pretty much done but before going any further I would like to know if there are things I really should change in the way I code things. I am pretty sure there will be a few things that could be done different, since I pretty much started with this project without any actual pri...
The following code is a self-implementation of the static class ThreadPool in C#, only the QueueUserWorkItem (the simpler method), written to practice multithreading in the .NET environment and generally C# coding. Implementation details: The background threads are simulated using Thread objects. Enqueuing and dequeui...
I'm beginning with PHP programming and would appreciate a critique on my code and how I could make it more efficient, rather than repeating the if statements. What I'm basically doing is getting the fields typed in by the user and displaying these fields in a sidebar of a custom page template. <?php $name...
I need to use this code to fetch data from web service and show them in a site properly but after I request for the webservice I am unable to load them fast. Site is loading very slow. <?php $jRequestURLPrefix = 'http://demo.4ds.com/rema/1.1/'; $menu_json_url = $jRequestURLPrefix."rules/origins/b2c.json"; $menu_dat...
A little while ago I wrote this implementation of Conway's Game of Life in Ruby. It's based on this Game of Life in APL video, which I think is rather elegant, though a bit dense. Feel free to give feedback on any aspect of the program, but the parts I most care about are readability and the way I work with matrices. U...
This class is responsible for storing an API Key and Secret pair. The secret is encrypted with AES in CFB mode, using a key derived from a passphrase, a random salt and a number of rounds of SHA1. An additional hash of the plaintext and the salt is stored to allow for detecting incorrect passphrase entry. This is teste...
I'm writing a script to archive email messages from one IMAP folder to another. It looks, more or less, like the following. I've obfuscated about 30 lines unrelated to this question: import imaplib import getpass def main(): user = getpass.getuser() + '@mymailbox.com' mailbox = imaplib.IMAP4_SSL('mymailbox.com...
I have a list of cities, and a set of "travel time" between any given two cities. The "travel time" is fixed and not necessarily dependent on absolute distance between the two cities, and it currently exists in an Excel doc that's manually maintained. I wanted users to be able to specify two cities from two dropdown me...
I always did my lookup in JSON collection like that: var data = [ { "Key": "1111-1111-1111", "Email": "test@test.com" } ]; function getByKey(key) { var found = null; for (var i = 0; i < data.length; i++) { var element = data[i]; if (element.Key == key) { fou...
I wrote simple lock-free collection class for saving items from multithreading code. I did it just for fun and experience. Can you check my code for potentially problems please? public class InputBox<T> { private BoxItem<T> _current; public InputBox() { _current = null;...
so this is my code for a equipping an item in my game dev't: try { $db = getConnection(); $db->beginTransaction(); $sql_chara_gold = $db->query("SELECT chara_gold FROM chara WHERE chara_id = $shop->chara_id"); $get_chara_gold = $sql_chara_gold->fetchColumn(); $sql_shop_pri...
I have this code to generate some tables in my PDF document for my Android app. It works fine, but I just think I need to refactor it as the same structure is repeated 3 times. //tables! public static PdfPTable createTableA() { //empty space Paragraph paragraph = new Paragraph(); addEmptyLine(p...
I have to check a string to various regular expressions in C++. Up to now, I've done this using something similar to this: regex regex_a (".."); string rewrite_a = "($1/$2)"; regex regex_b (".."); string rewrite_b = "($1)"; regex regex_c (".."); string rewrite_c = "($2)"; if (regex_match(string, regex_a)) { cout <...
I'm trying to implement a HashTable. In fact, I want a HashSet with Persons that have a name and a phoneNumber, both string. I understood the theory with collisions and everything but I don't know how to really implement something. This is what I've done so far: #ifndef HASHSET_H_ #define HASHSET_H_ #include <iostream...
I want to make a map object that key is object. But, JavaScript only allows string as a hash key. (at least before ECMAScript6 comes?) So, I tried to write auxiliary functions to emulate, hash-ish (but actually linear search). Are there any suggestions on improvement? var tabInfo = {}; var tabInfoKey = 0; function get...
I developed a QuickIndex class which serves to index arrays of stringafiable objects using a tree structure. The purpose is to then primarily to allow for fast index or include? method calls directed to the quick_index object as a proxy for the original array, as the index tree can be traversed much more efficiently th...
I am doing a redesign and have some previously existing content in HTML that is similar to <p class="testimonial-text">Bacon ipsum dolor sit amet aliquip est tail occaecat bacon ad qui short loin exercitation.Strip steak sint dolore et ut, elit kielbasa quis.</p> &ndash;<span class="person-name">Name Surname</span> <h...
I was looking over questions related to setting up markers on a Google map, and though the following works perfectly fine for me, it was different from the other (and accepted) answers. I just wanted to see if I'm doing something incorrect, or just a different way. Mine: this references the marker, and you can pull any...
I'm writing my first Java MVC application which should be a desktop student administration application with a Swing GUI. DAO is already implemented: Student administration application using a .csv file for persistence The application should provide a login form. After successful login there should be a different frame/...
In your opinion, do I need to do all these validations? I thought to do well and stay safe but it seriously raises the question if it isn't slower. jQuery $(document).ready(function () { // jQuery validate plugin $('#login > form').validate({ rules: { username: { required: ...
This takes a name, 2 images and a birthday for an artist, uploads images and insert info into MySQL. I seem to be missing something and I'm looking to see if I'm following best practices. <?php require_once '../config.php'; require 'includes/functions.php'; ?> <!DOCTYPE html> <html lang="en"> <head> <meta ...
This query is serving me a home page for users where a user can see all posts by him/her and his/her friends. This is an excellent query without any errors but I only wish to make it shorter if possible! select U.fname, U.lname, P.postid, P.status, P.date, U.usernick, P.visible from posts as P natural join users as U w...
Say I have 5 JTextField: jTextField1, jTextField2... Now I want them to behave the same on DocumentListener, so I decided to make only one DocumentListener and set it to the 5 components. Meanwhile I'm doing this: jTextField1.getDocument().putProperty("owner", jTextField1); jTextField2.getDocument().putProperty("owner...
I am looking for ways to improve my API wrapper for Pocket. So far, my code is quite compact and nice (I think), but I feel like there must be a better way to do this. This is the part where I think a lot of code redundancy due to different parameters that need to be serialized to Json and later send to server. ...
I recently asked to use eval() for a module function. Now I ended up doing a very weird function which does what I want. I like the idea I made it but I'm not so sure if this is state of the art, or more, good to build an application on. index.html: <script src="module.js"></script> <script> require('alert'); bam();...
I followed a tutorial to create a PHP contact form that sends to multiple emails depending on drop down field selection. Is it protected from spam/other dangers? Or is it basically wide open for bots and the like to gain access? I'm a beginner to PHP, and don't really understand what determines the safeness of this cod...
I'm willing to simplify the use of the ASP.NET cache. I wrote this helper class: public static class CacheHelper { public static T GetCached<T>(string key, Func<T> initializer, DateTime absoluteExpiration) { return GetCached(key, initializer, Cache.NoSlidingExpiration, absoluteExpiration); } pub...
I created this game in Java: import java.util.Scanner; public class TicTacToe { public static Scanner input = new Scanner(System.in); public static String getName(int noPlayer) { System.out.print("Enter name of Player " + noPlayer + ": "); return input.next(); } public static int getMove...
The last month I've been reading up on how to take my JavaScript code to the next level. I am a Java programmer at heart, so it feels nice when everything is encapsulated in classes/objects, and these are ready to be instantiated or inhertid or whatever. I wrote a simple test project with the purpose to refine my techn...
<?php session_start(); include_once("model/Model.php"); class Controller { public $model; public function __construct() { $this->model = new Model(); } public function invoke() { if (isset($_GET['page']) && $_GET['page'] == "registration") { if(isset($...
Project Euler problem 407: If we calculate a2 mod 6 for 0 ≤ a ≤ 5 we get: 0, 1, 4, 3, 4, 1. The largest value of a such that a2 mod 6 = a is 4. Let's call M(n) the largest value of a < n such that a2 mod n = a. So M(6) = 4. Find ΣM(n) for 1 ≤ n ≤ 107. So far, this is what I have: import time start = time.time() f...
This code works exactly as the prompt and the code predict. Is my style good, my implementations, or what should I change, or what? I'm trying to improve my code, and writing more of it helps... Any and all relevant feedback is good. #include <stdio.h> #include <time.h> #include <math.h> #define SECONDS_PER_MINUTE 60 ...
Could you please review the following? My concern is XML parsing is hardcoded: Ext.Ajax.request({ url: storageDataItem.contentlink, success: function (response) { var store; try { var parser = new DOMParser(); // TODO: remove extra lines or ig...
I have a comment system on 2 levels (like Blizzard http://eu.battle.net/sc2/en/blog/7935264/#c-7257875753), it's working fine but my code is a bit dirty : // $datacoms array from mysql_query foreach($datacoms as $com){ if(!$com->parent_id){ $level_id = $com->id; // include the view (display the com...
I have some hack-ey programming experience and recently made a Tic-Tac-Toe game in JavaScript. The game seems to work fine. I am looking for some constructive criticism to help understand what can be better. (full code in Github repo) function Player(name, selector, color) { this.name = name || ""; this.moves =...
This is my bare-bones Brainfuck interpreter in C using lots of unixisms. What improvements can I make (with respect to the clarity of code, or obvious features to add)? #include <assert.h> #include <stdlib.h> #include <stdio.h> #include <string.h> #include <sys/mman.h> #include <sys/types.h> #include <sys/stat.h> #incl...
This is code for finding largest prime number smaller than \$N\$, where \$N\$ can be as large as \$10^{18}\$. But, it takes 1 minute for \$10^{18}\$. I need to pass it in 2-3 sec. What changes should I make to pass it? My compiler used is g++ 4.3.2 The program here runs for multiple test cases. #include <iostream> #i...
I'd like to check my understanding and usage of the AutoMapper in my ASP.Net MVC app. I setup the maps in Application_Start: Mapper.CreateMap<Customer, CustomerViewModel>(); Mapper.CreateMap<CustomerViewModel, Customer>(); Mapper.AssertConfigurationIsValid(); To return a list of users associated with the logged in ...
I am using preg_replace_callback(), and I am concerned that I might have some sort of security risk. I am hoping to get a review of the below substitute() function. The purpose of the function is to parse a user provided template with user provided data. A quick description on how it is used is shown below. The user...
I'm new to programming and have created a simple Rock, Paper, Scissors game. The entire program is under a single class and the main method. I hear that's probably not the best way to code. How should I have written this to utilize multiple classes or to adhere to best practice? import java.util.Random; import java....
I am a backbone.js newbie. I have created a color picker application using backbone.js. I am trying to figure out if I have nailed the MVC concept. Please review my code and let me know if I can do better. <!DOCTYPE html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>MVC Design - ...
I have managed to write some pretty terrible code in VBA and I know there has to be a better way. I have made all of these variables to store some data which I eventually reference in the application. I'm fairly certain I need to loop over the recordset or fields and store the variables that way but I can't figure out...
I wrote a little ruby script to download issues of PragPub magazine and send them to my Kindle via email. I would love to get some feedback on it. One part, specifically, where I feel like there might be a better way is where it downloads the file and writes to disk. It used to do this: open(filepath, 'wb') do |file| ...
I have a simple Rails app, which is used to run some clinical surveys. Participants answer sets of questions (multiple-choice, valued 1-5), and, within each set, the answers are summed up and the resulting score placed into to certain score brackets, which are different for each set of questions, and for each participa...
I have an Order object that belongs_to a BillingAddress and a ShippingAddress. I want to present my user with only ShippingAddress fields and a checked checkbox indicating that the billing address matches the shipping address. If the user unchecks the box, the BillingAddress fields appear. This design proved painful to...
From a programming assignment: Write a method writeSequence that accepts an integer n as a parameter and prints a symmetric sequence of n numbers with descending integers ending in 1 followed by ascending integers beginning with 1, as in the table below: Call Output writeSequence(1); ...
Philosophical question: How far should I break down my objects? Inuit.css and Bootstrap have islands, islets, wells, grayboxes, and other objects that have repeating properties. I don't think it was DRY enough, so I created a generic .box object & a few skins. I am just not sure if this is overkill? Box Object Used to ...
Why does this Erlang code take about one minute on my machine? On Pascal something like this took less then second on my machine. What I can do to speed it up? -module(slow). -export([slow/0]). pyth(N) -> [{A, B, C} || A <- lists:seq(1, N - 2), B <- lists:seq(A + 1, N - 1), C <- lists:seq(B...
I am developing a C# Windows service that will always watch different folders/files and DB query results on different time intervals. There can be dozens of watchers each watching a specific file or folder or DB query results and sends emails at specific email address if some predefined threshold is met, and begins wat...
GOAL: Accept DSV strings where the delimiter may consist of more than one character Accept DSV strings where there are no embedded delimiters Output text with no modification to the source string other than aligning custom delimiter with optional padding QUESTION: Anyone have a re-factor or stylistic enhancement or ...
Would it be possible to get some feedback on some code I've just written? I've been working my way through Deitels' Java How to Program for the past few months and thought I'd better ask for some help before my bad coding habits get too ingrained. The current problem I've just been working on is this: (Airline Reserva...
I have a piece of code that divides a group of numbers into two groups of numbers of which the sums are equal. I created this because of a Stack Overflow question: For example: {10,15,20,5} will result in: {10,15} + {20,5} {1,2,3,4} will result in: {1,4} + {2,3} {5,5,5,15} will result in: {5,5,5} + {15} {5, 6} will ...
I'm just getting started with AJAX and am unsure of the best way to structure a PHP AJAX handler. I created a PHP file, ajax_handler.php, and the way I have it structured now is just a bunch of if-else statements (one for each AJAX event), like the following. First, I make sure there's actually a request being made: if...
I have implemented the Dining Philosopher problem using ReentrantLock in Java. The goal of this program is: Every philosopher should follow the workflow of think, getchopsticks, eat, putchopsticks (no race conditions). No Philosopher should be starving for food (no deadlocks and no starvation). Every Philosopher shoul...
I ran into a problem, I'm using MyIsam tables in mysql database, using PDO to connect. In all my tests (calling for 1 user everything works fine), now having around 300 users connected at the same time all day making requests is really really slowing down mySQL. Ive got my.cnf with (key_buffer=512M and max_connections=...
I am creating new elements for a webpage at run-time and I have code like this: var dynDiv = new System.Web.UI.HtmlControls.HtmlGenericControl("Div") {ID = "dynDiv"}; dynDiv.Style.Add(HtmlTextWriterStyle.BackgroundColor, "Red"); dynDiv.Style.Add(HtmlTextWriterStyle.Position, "absolute; left: 500px; to...
How do I elegantly check for null before calling a method on an object? This is how I do it right now: var title = document.querySelector('title'); title = title ? title.text : ''; Null Object pattern would be nice in this case but I don't own the document.querySelector code.
Preamble: it's a self-assigned and pure syntetic task to learn (and remember what I already knew) C# threads and synchronization and data structures. The original question was here https://stackoverflow.com/questions/16458937/synchronization-of-remote-files-download The short task explanation: Let's say I have a dictio...
I am struggling with the basic concepts of SASS. I have a page that has multiple section, all of them are sharing properties like width, font-size etc. I would like to optimize my code and do one of the following: 1. Use an extendable silent class %main-section{ width: 100%; //... more styles } .about { //...
I am looking for someone to review my solution to a jQuery DOM manipulation exercise on appendto.com: http://learn.appendto.com/lesson/dom-manipulation-101#exercise I'm wondering if there is a way I can optimize or if there are other aspects I need to consider when building a solution like this. The problem is outlined...
I need objects in python that I can compare, reference to and hash. In principal a tuple or list would be good enough just that a list I cannot hash and the tuple I cannot change, except replacing it which means losing references to it. So I created a class for it, but still have the feeling there should be a simpler/b...
when we need to add some javascript code to html, where we have to put it? What is the best practice: in line: <script type="text/javascript">document.write(new Date().getFullYear())</script> or centralized: <header><script type=text/javascript> document.getelementbyid('someid').innerhtml='date'.....</script></header...
.NET does not support generic numbers. It is not possible to enforce a generic method with generic argument T that T is a number. The following code will simply not compile: public T DifficultCalculation<T>(T a, T b) { T result = a * b + a; // <== WILL NOT COMPILE! return result; } Console.WriteLine(DifficultCa...
I am new to Java programming, and to help me learn, I created a simple telephone address book. The code runs as expected, but I would be interested to here from more advanced programmers if they think I should do it differently. import com.mongodb.MongoClient; import com.mongodb.MongoException; import com.mongodb.DB; ...
I have a running program. That accepts 1 to 15 variables The goal of the program was a simplifier. Based on the Quine–McCluskey algorithm Consider 3 variables 000 001 010 011 100 101 110 111 I group them by number of 1 000 001 010 100 011 101 110 111 Then I compare each string from the group to the next group grou...
What would be the most efficient way to write the following code in Perl: my $index = 0; foreach ( @spec ) { if ( $module =~ m/$_/ ) { splice(@spec, $index, 0, $module); last; } $index++; } This works fine but just seems a little wordy. ...
I would like an opinion on my code. I need a random access iterator for my custom container. If I read the C++ 2011 standard, specially chapter 24, I understood that an implementation could be the following: class my_iterator : public std::iterator<std::random_access_iterator_tag, my_element> { private: my_c...
Looking for a cleaner (possibly one liner) way to write the following my $spec_2d = ( ); foreach ( @spec ) { $spec_2d[$_][0] = $spec[$_]; } @spec = @spec_2d; Basically I'm making an array an array of arrays
I wrote John Conway's Game of Life in Java: class GameOfLife { static int countSurrounding(int[][] board, int a, int b) { int count = 0; int[][] surrounding = {{a - 1, b - 1}, {a - 1, b }, {a - 1, b + 1}, ...
I have code like the following, which performs a series of replacements on a string, to convert it to its final form. public String convertString(String string) { String convertedString = string; if( string.contains("something")) { convertedString = convertStringA(string); return convertedString; } else if (...
This is my first "large scale" system I've designed for myself. Since I'm more of a front end developer than backend developer, I'm not sure if my architecture is sound. I've created a Factory class which I use to create all my classes and connect to the DB. I think I've tried to use used Singelton(?) pattern, but I'm ...
I've written a short snippet of code to replace JQuery's $.post ( to get ride of JQuery, mainly ). The function does seem to work. But, since I might be using this function in a couple of other pages, I'm just hoping to get a general review of the code. I'm not confident the parameter formatting is done properly ( I co...
As I am getting my Linq query to a functional point, I start looking at the query and think about all the "ANY" and wonder if those should be a different method and then I have data conversions going on. Does anything jump out as being a performance issue? What is recommended to make this more performant? (Yes, I need ...
I am learning actionscript 3 coding by making a crappy platformer game :) The problem I am facing is passing lots of options to a construct function that will setup the display object where all of them have default values. I could send the options the normal way, like this: function Box(param1:Number=1, param2:Number=...
How can I improve my jQuery form preview implementation? I'm currently using the jQuery Instagram Plugin to get the hashtag from Instagram. var timeoutReference; var element; var tagsa; $(document).ready(function() { $('input#instagram_hashtag_hashtag').keypress(function() { if (timeoutReference) clearTimeout(t...
I have set up a basic MVC project which is a student administration application based upon a CSV file as datastore. Each user has a specific role (student, lecturer, professor, leader of degree program). After successful login, the main window should have different actions to be performed based upon each role. How can...
I've tried to create a small OpenGL abstraction layer. I've tried to favor composition over inheritance but somehow it added extra complexity to my code. I probably overused it. shader.h #ifndef SHADER_H #define SHADER_H #include "filereader.h" #include <string> #include <iostream> #include <GL/glew.h> #include <memory...
Here is the question followed by my working program: Given a string, return a version without the first 2 chars. Except keep the first char if it is 'a' and keep the second char if it is 'b'. The string may be any length. Harder than it looks. deFront("Hello") → "llo" deFront("java") → "va" deFront("away") → ...
Does the code below respect Python programming conventions? (and if not, which one does it disrespect?) The objective would be to publish this code as part of a scientific article, as "reproducible research". In 1998, Moffat and Turpin described in "Efficient Construction of Minimum Redundancy Codes for Large Alphabets...
I was writing a function (named listenString) in haskell to see if a string contains one of the strings in a list of strings, and to then return a value (of the type m ()) that corresponded with the string it found. The type of that function is (Eq a, Monad m) => [a] -> [([a], m ())] -> m (). The reason why I used a li...