instruction stringlengths 71 71.9k |
|---|
I made this code for a simple WinForm for my school project where I want to add other hash and encryption algorithms. I have made it following the algorithm of the official RFC 1321 and the Wikipedia page. I checked if the algorithm is correct by generating a hash and indeed it's working. However, are there any optimis... |
This simple program uses a socket class I wrote, class socket, to retrieve a users pop3 emails and print to stdout. I would like feedback on the socket class and the code to download the pop3 emails. My main focus is on the simple state machine to go through the steps required to download the messages. It looks a bi... |
This code draws a number of cubes on the screen selected from an array in one of three colours. How can I make it more efficient?
void DrawMap(){
levelParent=new GameObject();
levelParent.name="Level";
for (int x=1;x<complexity-1;x++){
for (int y=1;y<complexity-1;y++){
GameObject go;... |
I have a bash script I'm trying to distribute to people in my class. The script requires some dependencies to operate, namely wkhtmltopdf and pdfkit. I can install those dependencies with homebrew, but I can't assume users have that. I've written an install/uninstall script for Mac, and my partner made one for Linux, b... |
I am developing a small website with PHP and am trying to receive user exam scores from the database. I rank it based on the highest score and then store the ranking to the database based on the user_id returned from the database with the score.
I have finished the code but it's too long. I need optimizations and revie... |
I've built a countdown directive for a website I'm working on, and it actually functions just fine. It simply parses a given date, splits the total time remaining until that date up into Day, Hour, Minute, & Second components places them into the DOM, and then increments down until 0 is reached. What I'm not sure of is... |
I was recently given a Sudoku Puzzle to solve, and since I began solving many Sudoku puzzles after, I decided to attempt to create a Sudoku Puzzle viewer with JavaFX. I am not done yet, but have decided to split it into parts so that it is easier to fix future problems. Part 1 is the Sudoku class. The Sudoku class does... |
This implementation is the result of solving exercise 4-6 "Monge Arrays" from the book Introduction to algorithms.
Definition of a Monge Array:
An m x n array A of real numbers is a Monge array if for all \$i\$,
\$j\$, \$k\$, and \$l\$ such that \$1 \le i \lt k \le m\$ and \$1 \le j \lt l \le n\$, we have \$A[i, j]... |
Challenge:
Build an ad-hoc scanner for a calculator language.
Specifications:
The tokens for the language are as follows:
assign → :=
plus → +
minus → -
times → *
div → /
lparen → (
rparen → )
id → letter (letter|digit)*
number → digit digit * | digit * (.digit | digit.) digit *
-------excluding read and write
comm... |
I am trying to move from Python to a systems programming language so this is a bit of a challenge for me.
fn main() {
let mut total_pow = 0;
for x in 2..360000 {
let values: Vec<char> = x.to_string().chars().collect();
let mut total = 0;
for i in values {
let value = i.to_di... |
I am trying to calculate very large factorials. I am looking to speed it up as 10000! takes approximately a minute and a half.
extern crate num;
use num::bigint::BigInt;
use num::bigint::ToBigInt;
fn tree_fact(n: u64) -> BigInt {
if n < 2 {
return 1.to_bigint().unwrap();
}
return factorial(1, n)
}... |
The codes below is in DLL.
Here's the problems that I can identify:
1) Caller won't know what's the exception?
2) Catch exception 1 but throw exception 2.
3) num is not sum but overwrite.
What else?
These codes are in production, I just found it not well written.
I would like to get more feedback and is there any othe... |
Here's the second draft of my ADT stack code which I posted here before after carrying out most of the improvements suggested there.
I decided to expose a function called resize_stack to adjust the size of the stack as desired by the user instead of doing it automatically.
stacklib.h
#include <stdio.h>
#include <stdlib... |
I have this piece of code that executes update scripts on the database. I have 20 .sql files that contains about 400 update scripts. The overall size of the files is around 60MB. When I execute all the update scripts, it eats up about 400 MB of RAM and doesn't free it. I'm looking for ways to optimize this code.
privat... |
I need to model simple account data structure. The user should be able:
to add a transaction
get information about transaction
take all transaction of some type
sum a transaction and all its children
class AccountModel(object):
def __init__(self):
self.types = {}
self.amounts = {}
self.p... |
Having a general utility function to see if the input is empty makes sense to me. Empty means different things depends on the type. I just spent ~5 minutes writing this one up, so I'm sure it's missing edge cases, and maybe I'm approaching the whole problem incorrectly.
Function
function isEmpty(input: any) {
switc... |
This was inspired by a Stack Overflow question about getting all the classes of an application and I took it a little too seriously (or perhaps not seriously enough).
It's rather silly to do it this way, but I believe the code below is guaranteed to find every class exposed in the scope it is called from...eventually. ... |
Please review the code
package com.gmail.practice;
import java.util.Arrays;
public class StacksForTwo {
int size;
int[] stack;
int top1;
int top2;
public StacksForTwo(int arraysize)
{
size = arraysize;
stack = new int[size];
top1 = -1;
top2 = size;
... |
I'm having a WCF Rest service which does input parameter validation by using the IParameterInspector, before calling the actual service method. I have Implemented this functionality in my own way, but i have feeling that there may be some optimized way to implement this functionality. That is why I came here for a revi... |
What the code does (tested basic, no errors, usecase):
Reads all XML files (ending in .yin) from a directory.
converts each to JSON
store it in another directory, with the same basename as source file
... with .yin replaced by .json
Overt issues:
The code has too many nested functions
walk module's next() method in ... |
This is a follow-up of Wikipedia Trie pseudocode in Python
Code quality improvements
find has been fixed and a regression test ("bana" vs "banana") has been added so that it will never again be broken that way.
Used ordinary instance methods when sensible (previous code suffered from staticmethods overuse).
Significa... |
In onion arch. we have multi layer structre:
UI (User interface).
BL (Business Logic / Services).
RE (Repositories).
UI uses BL to get data from RE with some conditions, my question is which is better approach (as standard) to get data from BL:
In Repository (Data Access Layer):
public class PersonRepository
{
Perso... |
I always prefer to minimize the code, but sometimes I get into conflict with other people about the DRY concept.
In this simple example, which one would be a good choice?
function str_cleaner($str)
{
$str = trim($str);
$str = str_replace(".", "", $str);
$str = str_replace(",", "", $str);
$str = str_repl... |
I implemented the golden section search algorithm recursively in Lisp. My code is:
(defconstant phi 0.618033988749895D0)
(defun linemin (f x1 x2 &key (xi1 (- x2 (* (- x2 x1) phi)))
(xi2 (+ x1 (* (- x2 x1) phi)))
(tol 0.001))
(if (> tol (- xi2 xi1))
... |
I wrote this code for an assignment. It was originally meant to be written in Maple, but got very frustrated with some of Maple's idiosyncrasies that I decided to play around with Pandas instead. This is a very trivial multi-linear regression model, which calculates variable weights using least-squares optimisation, an... |
Problem Statement
The professor is conducting a course on Discrete Mathematics to a class of N students. He is angry at the lack of their discipline, and he decides to cancel the class if there are fewer than K students present after the class starts.
Given the arrival time of each student, your task is to find out if... |
I have a small (few elements) list of primary keys, sorted by hand. It come from user input. For example
$ids = [15, 75, 54, 13];
The SQL command is simple.
SELECT id, value, type FROM a_table WHERE id IN (15, 75, 45, 13);
This is SQL, so the order of output may be random. I want to
restore it in PHP. My first attem... |
I am a new .NET/C# developer and one issue bugs me ever since I've wrote code the first time. How can I improve this code?
Program.cs:
class Program
{
static void Main(string[] args)
{
App();
}
public static void App()
{
BankDetails bankdet = new Bank... |
I have written a NodeJS module and its tests to generate a URL, shorten it with Bitly, insert the short link in a tex file, compile these tex files to PDF and then merge them into one.
The code is working but it looks confusing and the tests are too hard to follow in my opinion.
I'm not sure if I should mock fs to avoi... |
This is a project I've been working on for a while. It's basically Cleverbot. What do you think?
import java.util.Scanner;
import java.util.Random;
public class Cleverbot {
public static void main(String[] args) {
String choice;
Scanner user_in = new Scanner(System.in);
/* add "why" to all, with answer being,... |
I have two tables Room and RoomDate. Here's the structure for Room
Room
roomID
checkInDate
checkOutDate
roomType
Here's the structure for RoomDate. They have a one to many relationship.
RoomDateID
checkInDate
checkOutDate
RoomID // foreign key
Now I want to find how many rooms per roomType are available in a specific... |
I want to build a grid and I have 2 concepts: Grid which is consist of Cell.
Grid class is:
var Grid = function (rows, columns, cellInit) {
var canvas = create_canvas();
this.context = canvas.getContext('2d');
this.matrix = new Array(rows);
for (var x = 0; x < rows; x+=1) {
this.matrix[x] = new... |
It's taking my machine quite a long time to execute 1 billion (1st loop x 10, 2nd loop x 1000, 3rd loop x 100,000) instructions. Suggestions for performance enhancements? Sources of potential concern:
global variables slower than local variables?
using for loops instead of something like map?
overhead for class instan... |
For a small personal project, I am looking to convert an object to an ordered by SemVer Markdown list. You can find the original code for the sort logic here and here for the writing into Markdown logic. I merged them to a full working snippet. I am using C# 5 in .NET 4.5.1.
Basically, the goal is to transform this:
va... |
I'm brand new here, but I've read the guidelines and looked at some up-voted questions. Hopefully I understand how I'm supposed to do this... if not, please let me know and I'll fix my question.
Explanation
I have written a simple javascript plugin of sorts. It takes the settings object for a jQuery.ajax request and a... |
type Suit = Club = 1 | Diamond = 2 | Spade = 3 | Heart = 4
type Rank = Two = 2 | Three = 3 | Four = 4 | Five = 5 | Six = 6 | Seven = 7 | Eight = 8 | Nine = 9 | Ten = 10 | Jack = 11 | Queen = 12 | King = 13 | Ace = 14
type Card = { Suit:Suit; Rank:Rank }
let RandomHand (size:int) =
let rndSuitIndex (rng... |
I've spent some time writing a library to parse JSON into a statically typed object. Am I following most of the standard coding guidelines? Any thoughts on what I could do better, or any edge cases that are missing and aren't taken care of?
private static T ParseDynamic(ExpandoObject input)
{
//Parse when given a... |
I usually write Euler solutions in Javascript. On problems requiring very large integers I have decided to learn Scala and take advantage of BigInt. I wrote a solution to Euler025, it works fast but reads like Javascript. Will the reviewer please comment on how to write this solution more idiomatically and, if you have... |
I'm currently running through some Cracking the Coding Interview questions and my solution to 4-4 is quite different from any of the given solutions.
The question asks to determine if a given binary tree is balanced; more specifically, if the difference between the maximum and minimum depths within the tree is less tha... |
I have a list of patients, Patient class has Prescriptions property, which is a list of Prescription objects. Prescription has 3 important attributes, Medicament,Amount and Type(which is basically a key for joining).
I need to join a list of Prescription types, as a prescription type has an attribute Influence which se... |
Still oiling my Forth. Below are few essential algorithms for in-place merge. Please review.
Some introductory comments:
>swap< is not a cute smiley. I am trying to tell that two pointers are going towards each other at each swap.
rdrop drop looks hideously ugly. Any suggestions?
lower-bound and upper-bound must be un... |
This is my code for a very basic video game I created today. I did not create this to be a fun game to play. I created this to test my skills on conditional coding, etc. Please critique this.
// Created by Andrew Tew
// My Test Studio
#include <iostream>
#include <string>
using namespace std;
int main ()
{
string yay... |
I am trying to experiment with golang.
This code spins off two Go routines: one to download data and another to read from the body. Both go threads are synced by the data channel.
I have two questions:
Should I have to dispose the body inside downloadData method?
Is this type of coding acceptable in Go?
package main
... |
Problem Statement
You are given N sticks, where the length of each stick is a positive integer. A cut operation is performed on the sticks such that all of them are reduced by the length of the smallest stick.
Suppose we have six sticks of the following lengths:
\$5, 4, 4, 2, 2, 8\$
Then, in one cut operation we make ... |
ROT13 ("rotate by 13 places", sometimes hyphenated ROT-13) is a simple letter substitution cipher that replaces a letter with the letter 13 letters after it in the alphabet. ROT13 is a special case of the Caesar cipher, developed in ancient Rome.
ROT47 is a derivative of ROT13 which, in addition to scrambling the basi... |
I have a class which takes the method address and arguments, and executes it later when told to do so.
' need to turn option strict off due to Execute method executing late-bound code
Option Strict Off
Public Class WorkItem
Private Action As Object
Private Args() As Object
Public Overloads Sub [Set](actio... |
I'm wondering if this code can be simplified. I'm less than thrilled about the fact that I repeat the Draw method in both CatModel and DogModel. For that matter, I'm not real happy that that method is even in the models at all. Trying to move it up to the AnimalModel superclass forces a cast.
EDIT: The "Model" classes ... |
I'm a beginner to web programming and just started a MVC project from scratch. Because this will become a large project eventually, I would like to make sure that I'm doing things kind of right from the beginning.
The architecture is the following: ASP.NET 4.6, MVC 5, EF 6, Identity 2.0. I'm using EF Database First ap... |
Since the repetition mode didn't make to HTML5, I was wondering how to succinctly implement it in Javascript. I've already spent a few hours on this jsbin. Be great to get a review.
<button onclick="addRow();">Add row</button>
<label>Pence per kiloWatt hour
<input id="price" required type="number" step="0.1" v... |
I have been trying to convert a string of dictionary objects as given below
"{'Cmd': None, 'Hostname': None, 'Entrypoint': None, 'Env': None, 'OpenStdin': False,
'Tty': False, 'Domainname': None, 'Image': u'nginx:latest', 'HostConfig':
{'Binds': None, 'RestartPolicy': {}, 'NetworkMode': u'bridge', 'Dns': None, ... |
I've got a VARCHAR variable of this kind:
@string = "BLABLA10;GOGOGO30;RES777;ANOTHER;"
(several keyword + number separated by ;)
I need to get the INT value after "RES" in a T-SQL query (using SYBASE).
I thought it would be always 3 characters, so I did:
SELECT @val = CONVERT(INT, LTRIM(RTRIM(SUBSTRING(@string, CHARI... |
This is the Tractor problem from the Kattis problems archive.
Problem Statement
Bessie the Cow has stolen Farmer John’s tractor and is running wild on the coordinate plane! She, however, is a terrible driver, and can only move according to the following rules:
Each of her movements is in the same direction as either t... |
I tried to sample up a logging class from this question and answer(I want to use this class from C# DLL).
Made slight modification mainly to file name, and also how data is written.
I am interested if this can be considered thread safe logging class?
I am particularly concerned by the comment under the answer. See belo... |
I've written this Python script to make regular backups of a Linux server. It works pretty well except that the script sometimes backups files more than one time, which is pretty strange and I don't know why that happens.
But that's not the key point of my posting here (just someone may see a little error I've made whi... |
Problem description:
The task is to calculate the amount of money earned from roller
coaster rides on any given day. There is a queue in front of the
attraction. Visitors might be alone or in groups. All members of
the same group will want to ride together. The ride begins once
the roller coaster runs out o... |
When it comes to the Umbraco CMS, there are components called "Macro-Scripts" which are essentially a Razor View (.cshtml). They allow you to code a bunch of C# and HTML in a page and display this "Macro-Script" on any CMS page that you choose.
In my tutorial (which I completed well over 2 months ago), I thought I reme... |
I've been starting to learn Rust by going through some of the Rosalind String Algorithm problems.
If anyone would like to point out possible improvements, or anything else, that would be great. There are a couple of things I'm especially curious about noted in the subs and lcsm solutions.
main.rs:
mod utils;
mod string... |
Please review this code, considering I put emphasis on constraining space complexity at the expense of execution speed (accepting additional branching).
Can you see cases that prove the algorithm incorrect?
Could you improve its execution speed without increasing space complexity?
Could you make it more readable?
Met... |
Is there a better or shorthand way to perform a check on whether or not a variable within (possibly several levels of) an object is null or undefined?
What I would currently do to check is:
if (typeof json !== 'undefined' || typeof json.data !== 'undefined' || typeof json.data.formkeys !== 'undefined') {}
Is there a s... |
I'm trying to add a link to a page. The link should contain the current URL in a querystring (to be used as a ReturnUrl) and it can contain a hash.
Middle-clicking, right-clicking and ctrl+clicking should be supported. For example, middle-clicking will open the link in a new tab with (or without) the querystring.
Is t... |
I have a hash map which maps to some strings which serve as prefixes and are of small length (max length is 6):
Map<String, String> map = new HashMap<>();
map.put("codeA", "100");
map.put("codeB", "7");
map.put("codeC", "0012");
etc
This is fine so far, but I also need when provided an input string to actual... |
EnumSpace
This file enables the use of a utility I like to call "EnumSpace". This utility is enums and namespaces combined together in order to create an entity that acts like an enum that is able to inherit and extend an already existing one.
It provides three macros for that purpose:
ENUMSPACE_CREATE
ENUMSPACE_EXTEN... |
I have this function which will fire off a specific template depending on which element is selected. However, with the way it is, I'd have to update the JavaScript and the HTML when a new element is added. What I'd like is to have the function scale up to as many HTML elements one would add.
So far I have figured out i... |
I've come up with a prime number finder I call the "Progressive Sieve". I wouldn't doubt it if this has already been thought of. Anyway, here is the idea, an implementation in C#, and benchmarks:
Premise: A number is prime if it cannot be divided evenly by any prime number below its square root.
Implementation:
stati... |
I'm trying to make a program which prints different sized grids (n by n grids).
These grids cannot have the same number in any column or row (like a Sudoku).
My bruteSolve() method runs through every combination and then isValid() checks if the rows and columns add up & multiply up to a certain number too - if they d... |
Introduction
The function divides a range given by a begin_iterator and an end_iterator into n sub-ranges of the same format, where the sub-ranges must be as equally sized as possible.
Example
Consider a set of size 10:
\$\{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 \}\$
The output would be is a set of n = 3 sub-ranges:
\$\{ \{ ... |
I worked through the Flowers challenge on hackerrank.com and would like to get feedback on solution and algorithm implementation. It was suggested by hackerrank to review greedy algorithm to solve this challenge. As far as I understand this is an implementation of greedy algorithm.
You and your \$K−1\$ friends want ... |
What my code does is that it takes input as to which function to use, and then plugs in the appropriate data in to the given function.
For example:
User input: force(1, density = 10.0, volume = 5.0)
Result: 490.5
The 1 is the equation ID, and the rest are user parameters
import Constants as C
import Errors as E
def ... |
I'm a C# developer looking to learn more about Python and how to think in a more functional programming manner.
I have the following which takes a series of grades and returns the average:
grades = [100, 100, 90, 40, 80, 100, 85, 70, 90, 65, 90, 85, 50.5]
def grades_sum(scores):
total = 0
for score in scores:
... |
I wrote some code using ChucK : Strongly-timed, Concurrent, and On-the-fly
Music Programming Language and would like a review. I broke down the logic into a number of classes, all of which are shown below.
This is pretty new to me, and I would appreciate any and all constructive criticism. What the main script fizzbu... |
in-nest-sequence is a sequence generator that takes a function and an initial value, and the return value of invoking the function on the current value is used as the subsequent value. For example, (in-nest-sequence add1 0) returns the sequence (0 1 2 3 4 ...).
Recently, soegaard challenged me to write a define-sequenc... |
From this question and some help I created a thread safe logging class on which the name of the log file is same as the current date (short date) when the log entry was added. e.g. If I create ten entries today say they will all get written to log file named "07.10.2015.txt". I want to use this class from DLL.
I am cur... |
I have a Spring/Hibernate application with the following domain class (irrelevant code stripped for brevity):
@Entity
@Data
public class Program implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long tid;
@Column
@Convert(converter = ProgramStatusConverter.class... |
I'm learning data structures. I'm working on linked lists at the moment, and I'd like to have a strong grasp on them. Below is the last problem I solved. I'd like to know what you think of the solution and what can be done better.
The problem consists of reversing a linked list from position m to position n.
1 ≤ m ≤ n... |
Prompted by a meta answer, here is an HTML page I'm deliberating over in JSBIN and I would like your review, please.
I am not looking to implement the logic, just please focus on HTML & CSS.
Are tables a good candidate to mark up purchase items? I've seen this implemented as a list in each column, which I thought was ... |
I created a very simple interpreter in Python. It's capable of doing basic math (unfortunately with only two numbers), creating quines and printing text.
import re
def prompt():
userInput = input("> ")
return userInput
def parse(command):
if command.startswith("+"):
numbers = re.findall(r'\d+', co... |
Here are three classes in my project. They work as expected. What I'm not sure of is the passing of the target into style sheet. What is going on is that I want the matrix as a whole to be left-aligned on the screen, but each entry to be centered within its column. The GetHorizontalAlignmentQ method accomplishes that.
... |
I am trying to get the hang of Roslyn at the moment, and to implement a couple of code fixes for specific fields/properties that should usually be readonly (in the case of a property, to have no setter).
I've started from the "Analyzer with Code Fix (NUGET + VSIX)" template and now have two diagnostics implemented in t... |
I have to sort some numbers with Perl. But some of the numbers are undefined. Perl's compare operator <=> treats undef as -inf 0. The result is, that the undefined numbers are at the beginning:
perl -MData::Dumper -e 'print Dumper(sort {$a <=> $b} 3, undef, 2, 1);'
$VAR1 = undef;
$VAR2 = 1;
$VAR3 = 2;
$VAR4 = 3;
I wan... |
I've just created my first set of related classes in React and would like to get feedback from more experienced React developers.
I've used ES and completely vanilla React. The application is a shopping cart where the cart item quantities update the totals.
The one file situation is because it didn't seem to like multi... |
I have the following concerns:
Is Set a good choice for getting products? What are drawbacks of Set for this purpose?
Is it better to do something like common.retainAll() or to get products through a request with WHERE to the database. For now I do three requests in: getProductsByCategory, getProductsByManufacturer, g... |
This function iterates through a open dialog box that has 4 values in it all optional except for aircraft1, aircraft2, warning_or_alert.
aircraft1, aircraft2
t_sep # time value in format 00:12:21
t_min_nm # time value in format 00:21:21
c_tracks # can be either 'on' or 'off'
warning_or_alert # can be either 'wa... |
I missed points for putting implementation in the driver class, rather than having the driver class only make call methods in other classes. I'm not sure how to move the implementation outside of the main class. Suggestions are welcome!
/*
*Deitel Chapter 6 Exercise 6.30
*/
package guess;
import java.util.Scanner;
/... |
I'm trying to learn more about object oriented programming and I have a few questions about the class below.
I'm working in Visual Basic.NET
My questions are
Is there a better place / way to show the MessageBox.Show?
I'm being forced to use a single Oracle Connection, in my sample cnn is declared with Friend scope so ... |
I'm using VB.Net, MVC 5, EF 6, and Linq. I have a list of Integers (category attribute IDs). I need to create a second list of String (values). There will be one string for each integer.
I am currently accomplishing my task like this:
Function getValues(catAttIDs As List(Of Integer), itemID As Integer) As List(Of St... |
Just curious if my authentication is secure enough, really. Also wondering if I should ditch the secret variable and just use password everywhere instead.
Note: the method logic must remain seperated because the same User object will have CRUD methods added at a later date.
The table structure:
CREATE TABLE IF NOT EXIS... |
I was asked this as an interview question. I was also asked to assume that there is a function which can compare and say two nodes are identical. I would like to implement that function as well. I'm not sure what's a sure shot way of saying that in pure JavaScript.
O O
/ \ / \
O O O O
... |
public static int lastDigit(int a) {
a = a % 10;
if (a <= 0){
a *= -1;
}
return a;
}
This is my solution. The course hasn't taught if else yet, so I'm wondering if there is a way to do it without the if else.
public static int lastDigit(int a) {
a = a % 10;
return a;
}
The problem with this is tha... |
I just watched Raymond Hettinger's talk on making Python more Pythonic and realized I should be putting a lot of his ideas into practice, particularly wrapping API's in a class that makes everything simpler and easy to use. Here's what I'm doing to wrap PyMongo:
from pymongo import MongoClient
class MongoDB(object):
... |
This is code that's part of a library (closed source) that I have that generates a unique nonce value for Twitter OAuth. Essentially, it generates a random number, combines it in string form with an extra string separated by a pipe, computes a Sha-1 hash, and then repeats the process if the Sha-1 hash (when converted t... |
This is part of my first OCaml program.
Its job is to replace a set of placeholder characters with umlauts. Taking the German word Ruebe as an example, the program turns it into Rübe. Other examples are Moewe -> Möwe and aendern -> ändern
Generally, everytime the program encounters the characters ae, oe, and ue it turn... |
I've already expressed concerns about this type's constructor, and I've sort-of* implemented the changes suggested in the answers I got there.
Recently I added even more parameters to that constructor - namely the ParentDeclaration and the Annotations. The Declaration type is absolutely where these things belong. For e... |
Today I stumbled upon CodinGame, a site with programming challenges. I'll describe one of them.
ASCII art allows you to represent forms by using characters. To be precise, in our case, these forms are words. For example, the word "MANHATTAN" could be displayed as follows in ASCII art:
# # # ### # # # ### ### # #... |
I want to know how I can make this old code faster, cleaner and compact. It may look like bad code because I did it when I first started with Python.
# -*- coding: utf-8 -*-
import urllib
import time
import os
from twython import Twython
from bs4 import BeautifulSoup as bs
class Alfred():
def __init__(self):
... |
From my C university book 'The C Programming Language' by Brain W.Kernighan and Dennis M.Ritchie. Excercise 1 - 20.
Write a program detab that replaces tabs in the input with the proper number of
blanks to space to the next tab stop.
Assume a fixed set of tab stops, say every
n columns. Should n be a va... |
I am stepping into a new realm with this project, Reflection. I have written some working code (below) that will potentially store POCO objects in a redis cache (and eventually backed by Table or other nosql persistant storage).
Currently it only reads the objects from the cache, but after this review I will be attempt... |
I've written a simple little Groovy class handling my database interactions. All it has to do is check if a row exists in a target table with primary key values which match those of an incoming map. If a row exists, it updates the row based on the differing non-primary key values; otherwise, a new row is inserted.
impo... |
Does anyone have tips to improve the speed, clarity and accuracy of this non-recursive alpha-beta algorithm? It's my first program written in C.
// Tic-Tac-Toe - Iterative implementation of alpha beta tree search.
// Built with Microsoft Visual Studio Professional 2013.
#include "stdafx.h"
#include <windows.h>
#inclu... |
This is a multiple choice game. It has a web page where you enter a question, which can have multiple answers along with multiple options.
Can anyone recommend any improvements for my code?
//correct & options are both arrays. These arrays are being passed through an AJAX call
function addQuestion($topicID, $difficulty... |
This takes a list of categories and organizes them into a tree-type structure based on their parentId. This code works, but is obviously a little over-complicated. How can I optimize it?
type ValidString = | ValidString of string | NotValid
type CategoryStructure = {
Id: ValidString;
ParentId: ValidString;
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.