instruction stringlengths 71 71.9k |
|---|
For this community challenge I made the racetrack game. I'm reading the race data from a text file, which is available here. This is only playable by entering the velocity at the console.
I've got two modules. I'm open for any comments.
Racetrack.hs
import Data.Serialize
import qualified Data.ByteString.Char8 as BStr
i... |
I decided to implement properly the Code Golf challenge about twisting strings. I report the assignement verbatim for convenience:
Twisting Words!
Given a string and a positive integer. You must twist the string, back
and forth.
Example Input / Output
Input
Programming Puzzles & Code Golf
4
Output
Prog
mmar
ing
z... |
I created my first shell script. It's an audio logger that runs on the hour for an hour and restarts. Although if it is started within the hour it will only run until the end of the hour.
I've added it to Startup Applications with the command:
gnome-terminal -e /home/admin/Desktop/audiolog.sh
However when it starts up... |
guys.
The code below is spring security web adapter. I do not like configure(HttpSecurity) method that generates security confirmation policy.
Any ideas to do it more readable and clear?
/**
* Spring security configuration
*
* @author Eugene Ustimenko
* @date Nov 5, 2014
*/
@Configuration
@EnableWebSecurity
public clas... |
This code is about manipulating each value in a 2D array. My method below is called based on how I want the values in the array to be manipulated (process).
For the first method in the switch statement - as an example, I am calling AllCaps() method to manipulate the value.
What I am trying to avoid is repeating stateme... |
What I've hastily named the Scissors API brings the cut-copy-paste paradigm made popular by word processors to the realm of list processing. The Scissors API is fluent, provides methods to manipulate a list, and maintains context through the use of a customizable clipboard.
An example: Fixing Yoda’s grammar
A good star... |
I gave a shot at implementing Maybe for C++ and a slight twist in my implementation is that it uses thread_local static instance of Just and Nothing + placement new operator to minimize the number of (de)allocations.
This is the first time I'm using thread_local and placement new operator, so I could be doing something... |
I have a class Address, a class AddressTest and I am trying to write unit tests for its constructors and getter setters.
Address:
/**
* The bean Address.
*
* @author Sandeep Chatterjee
* @since 24/8/2015
*/
class Address {
private BigInteger addressId;
private String name;
private String address;
... |
What would be the best way to refactor following methods?
private string CalcualtePercentageDifference(string temp1, string temp2)
{
double number1 = ParseDouble(temp1);
double number2 = ParseDouble(temp2);
double percentageDifference = 0;
if (number1 == 0 || number2 == 0)
... |
Following a lot of research and mainly based on this tutorial I came up with the following structure in my application:
ObjectBase - all view models inherit it:
public abstract class ObjectBase : INotifyPropertyChanged
{
#region INotifyPropertyChanged
public event PropertyChangedEventHandler PropertyChanged = ... |
First off, this is version 2 of a previous question about the same macro: Previous Version. Thank you to Raystafarian, RubberDuck and everyone in chat who helped me make it better.
The Macro accesses a workbook containing 8 worksheets each with similarly structured but not identical tables of data (submitted business f... |
How can I improve this window timeout alert code? I need to add it to some third-party master page and don't want to add a separate file for it.
It must be JS only and IE-8 supported.
jsFiddle
(function () {
// timedRefresh(10); //3600000
delayedAlert();
var timeoutID;
function delayedAlert() {
... |
I've made a simple HTML→Markdown converter in Javascript and am looking for any feedback. For now, I've basically used Stack Exchange's /editing-help as a guide as to what to convert, but I might look at CommonMark's spec later on.
It uses DOMParser() and then goes through the child nodes to convert things.
My test HTM... |
Write a method rarest that accepts a map whose keys are strings and
whose values are integers as a parameter and returns the integer value
that occurs the fewest times in the map. If there is a tie, return the
smaller integer value. If the map is empty, throw an exception.
For example, suppose the map contains mapping... |
I think this code looks ugly, especially with the multiple try-catch blocks, but I don't know how to rewrite it:
public String handleFileUpload(@RequestParam String url,@RequestParam String fileName, RedirectAttributes redirectAttributes, HttpServletResponse response) {
InputStream inputStream;
try {
... |
I run a tiny open source project to help create speech aids for disabled people (the GitHub is here).
One of the things that is useful is for people to design speech setups in Powerpoint, and then have the PowerPoint file processed to extract the images and the other information. The script below processes the PowerP... |
Currently I have an application that is relying on Bootstrap's Grid layout. I originally chose it because it was easy to learn and looked good. However, it didn't handle nesting as well as I thought it would. After investigating and finding out that it used float for all the grid classes, I don't like it as much.
... |
I am solving problem GRAVITY on SPOJ. Each test case is a rectangular ASCII grid of dimensions m × n, and you have to determine whether it is possible to find a path from the 'S' square to the 'T' square, moving using the space squares and avoiding '#' obstacles, in at most O steps (diagonal steps allowed).
I am using ... |
I actually had a real life need (outside work, no less) to come up with every single permutation of N elements (the N in my case being 12, so a total of 12! = 479,001,600) and run each one against a simple evaluation to produce some metric in order to determine which permutation is the most optimal.
Since I have some b... |
This code puts or changes ID3 tags to media files based on their file names. It assumes the files are in this format:
morbid angel - maze of torment.mp3
The resulting tag would be:
Artist: morbid angel
Title: maze of torment
I use boost::filesystem to iterate through the directory and taglib to manipulate the ta... |
I while ago I experimented with macros in C and came up with the idea of implementing a generic vector library using macros.
This code uses the non standard typeof extension that returns the type of an expression.
#ifndef VECTOR_H
#define VECTOR_H
#include <stdlib.h>
#include <string.h>
#define VECTOR_OF(T) struct { ... |
I've written a 'Mini Twitter' (that's what I've called it) in Python. It includes a text-based login screen and user panel where you can create Tweets, and change your username and password.
Users' names, passwords and whether or not it is an administrator is logged in a text file. It also logs Tweets Users have made i... |
I am looking for the best way of parsing JSON in Swift 2.0.
I have this JSON
{
"latitude": 37.8267,
"longitude": -122.423,
"currently": {
"time": 1440110395,
"summary": "Clear"
}
}
and field summary is NOT always visible in response.
My model object and parsing method:
enum JSONErrorType: ErrorType {... |
This is a calculator I've made in C#. Is there any way to improve it? Surely there is a way to get rid of all the ifs that are nested inside one another.
namespace CalculatorCA
{
using System;
using System.Collections.Generic;
class Program
{
static void Main()
{
Dictionary<i... |
I have been told that it would be wise to split up my code into semantically useful blocks. I tried the following but I need feedback.
What I already did:
As you can see I create two .csv files, so it seemed logical to have two functions. One for the main dataset, the other for a frequency table
I only import modules ... |
As a follow-up to this question concerning Python I present you with the exact same thing - for R.
Initially I started with R. However, it takes 44 minutes to run when unleashed on all my data. I then looked for an alternative. I read about Python and got advised to use pandas by a colleague. So I set out on an advent... |
I want to know about best practice for this SplashScreen class:
public class SplashScreen extends Activity {
// time out to splash screen
private static int SPLASH_TIME_OUT = 2000;
private Runnable mjumpRunnable;
private Handler mHandler;
//image view to validae logo
ImageView validatelogo;
... |
This is an interview problem:
Given a token stream, find the K most frequent tokens in real time (the order of these k tokens does not matter).
My approach:
Use a hash table (unordered_map in c++) to maintain the frequency of tokens.
Use a min heap to maintain the k most frequent tokens.
Update the hash table and th... |
I have implemented a solution to Project Euler problem #60. In summary, the problem asks to find the smallest sum of a set of five prime numbers such that the decimal strings of any two numbers in the set concatenated together form the decimal string of a prime.
I'd like some comments on the structure and style of my p... |
I'm new to Haskell and am confused by why my code seems to preform so poorly, and wonder if there's something I've not grasped about the coding philosophy behind the language, or the best way to take advantage of its features.
For example, I have started, as an exercise (yet another) simple Enigma machine simulator (fo... |
I haven't written any Java in years and I wanted to catch up a little, especially on newer features. I started looking at streams and aggregate operations and came up with the following solution to Project Euler #7 (find the 10001st prime).
package com.example;
import java.util.stream.IntStream;
import org.apache.commo... |
After populating the stock_tmp table, i'm running these SQL queries via legacy mysqli wrapper code. I don't think this code needs additional locks to prevent people from seeing incorrect data. Is that correct?
DELETE FROM stock WHERE ean NOT IN (SELECT ean FROM stock_tmp);
REPLACE INTO stock SELECT * FROM stock_tmp;
|
I have code that converts each character of a String to an int and returns the difference between odd and even numbers. Can this code be simplified?
int compareSumOfDigits(String N) {
int e=0,o=0;
for (int i =0;i<N.length();i++){
int t = Character.getNumericValue(N.charAt(i));
if(t%2==0)
e+=t;
else
o+=t... |
I have a class Fighter in a software for planning boxing events. I implemented its hashCode() and equals() since I collect them in various data structures in many places.
Now I want to persist specific planned boxing events which themselves contain the same Fighters in different lists. I am using JAXB for this purpo... |
I created a basic jQuery plugin to make a basic sliding tile puzzle.
/*
* tilePuzzle.src.js
*
* A simple tile puzzle jQuery plugin by @matthewfedak
*
*/
/*jslint browser: true*/
/*global $, jQuery, alert*/
(function ($) {
"use strict";
$.fn.tilePuzzle = function (options) {
var self = $(this);
var t... |
Here is my script that registers a user to a database. I am still very much a newbie when it comes to this topic so any guidance would be greatly appreciated.
<html>
<head>
<title>Register</title>
</head>
<body>
<?php
require ("opendboLogin.php");
main();
function main()
{
if(!isset($_POST['submit'])) //if user t... |
I'm working with some Clojurescript code that reacts to user input over three sliders. These sliders get stored in a map, and I need to make sure that the sum of all is <= a max value. Every time a value from the map is modified I have the guarantee that it will be in the [0, max] range, and I must reduce if necessary ... |
I'm designing a Factory in C++ with raw pointers, but I'd like to use smart pointers when possible as is recommended with the Factory pattern in newer C++. Unfortunately my compiler is a bit old (gcc 4.4.6) and not all of the features of C++11 (let alone C++0x) are available to me.
I cannot use nullptr, which is the mo... |
This code inserts the number 4 into a vector's even indexes.
vector<double> vecCoeffs;
// Put the coefficient 4 into each even index and 2 for each odd index
for(int i = 0; i <= 10; i++){
vecCoeffs[i];
if(i % 2 == 0 ){
vecCoeffs.push_back(4);
}else{
vecCoeffs.push... |
int Octet(double m, int Ax, int Ay, int Bx, int By)
{
int octetNo = -1;
double dx = Bx - Ax;
double dy = By - Ay;
//m = dy / dx;
if(0<=m && m<=1)
{
if(Ax<Bx) octetNo = 1;
else if(Bx<Ax) octetNo = 5;
}
else if(0>=m && m>=-1)
{
if(Bx<Ax)
octetNo =... |
I need to send and receive data. Here is solution for my original problem. I want to know how safe my finished code is and how I can improve it. Here is my first try. Now I need to get review for my new code.
void sslWrite(SSL *ssl, const void *buf, unsigned size)
{
int writedTotal = 0;
const char *ccBuf = re... |
I've made an "simple" / "small" MVC-like PHP system. I've used some code of an project I used before and ask questions about it back then to.
The thing is, it works (the admin part to begin with), but I'm not sure about the quality of the code. I know that there are mainly no comments, but they will be added when I'm s... |
I built a couple Vector2 structures (Vector2 and Vector2F) for use with a particular project, so I'm mostly requesting best practices here.
The biggest concern is that I'm not making any assumptions I shouldn't be. I would like any comments that are relevant on the interface and whether it's too light, or if it's just ... |
This Macro takes my company's 2 main sources of all-client data (each a data table in a separate worksheet) and aggregates them into a 3rd list, by matching a unique account number (for clients that have an account number).
As always, I'm welcome to all feedback on any aspect of the Code and in particular, I'm interest... |
I'm trying to find my bug or any potential bottleneck that cause my program to be really slow. The script is to get all the followers and friends and save that in MongoDB.
import pymongo
import tweepy
consumer_key = ''
consumer_secret = ''
access_token = ''
access_token_secret = ''
from pymongo import MongoClient
cli... |
If anyone has the patience to take a look at my first python snake game, I'd be very grateful for any feedback. I am fairly new to programming and Python, but am looking to improve so any constructive feedback is appreciated.
import Tkinter
import time
import random
UP = u'\uf700'
DOWN = u'\uf701'
LEFT = u"\uf702"
RIG... |
I tried to find a generic way to deal with associations. I ended up with this code which seems to fit my needs:
#include <iostream>
#include <tuple>
#include <set>
#include <string>
template <typename D, typename... Ts>
class Relations;
namespace std
{
template <std::size_t I, typename D, typename... Ts>
auto... |
I have two javascript functions that generate a D3 Stream graph. I feel I may be excessively and unnecessarily iterating over my dataset to get it into the desired form.
How might I optimize or simplify this?
d3.json("/sleeps", function(d) {
sleepStream(d);
});
function sleepStream(d) ... |
The idea here is to pick a skill at random for the player each round. Four skills will be chosen, they are all random, and the same skill can repeat multiple times.
The player has a skill level for each ability. The higher the skill level, the greater the chance that the skill will be chosen.
Rather than use floats a... |
Here is the original question. I've incorporated a lot of the feedback and I'm ready for another round of feedback and suggestions.
Here is the PHP file's output. It creates a volunteer signup report (in HTML, viewable in your browser, based on data in an SQL database) for volunteer managers to review. I plan to use th... |
I wrote Ruby code (copied below) but was told that the code does not compile (it does on my computer) and that it does not answer the question:
Create a class called Scrabble that implements a method called score that accepts one word as a parameter and returns the scrabble score associated with that word
The code co... |
I have an ordering system that uses SharePoint. Below I've included a small snapshot of the system that is used in a WPF form when the user clicks a button to refresh the order listing. The outcome is a populated WPF datagrid. Note that this code is using C# 6.0 as well.
Everything works well, and it's quite quick, but... |
I have the following code to share my website through some social networks when the user clicks some divs with the appropriate icons.
var loc = encodeURIComponent(document.location.href);
$(document).ready(function() {
$("#shareFacebook").click(function() {
window.open('https://www.facebook.com/sharer/sharer.ph... |
I'm tying to convert from this formatted string:
$filtersStr = "id:1||name:alex";
to:
['id' => 1,'name' => 'alex']
My solution for now:
foreach(explode('||', $filtersStr) as $filter){
list($k, $v) = explode(':', $filter);
$filters[ $k ] = $v;
}
I'm looking for a more elegant way.
|
In my Angular app, users click on different icons. When a user clicks on respective icon, I can show the icons gallery, as well shuffle the view.
Apart from this shuffling functionality, I need to hide whatever other gallery is already open.
For that, I've written the following function, but, I think it could use some ... |
This is a follow-up question: Game server packet handler
I have applied most of the suggestions and now the code looks like this:
import java.io.IOException;
import server.engine.*;
public class ServerPacketHandler extends PacketHandler {
@Override
public void handlePacket(final Packet p) throws ArrayIndexOut... |
I have been trying to solve the following problem on hackerrank.com, but when I submit the code it shows unsuccessful submission due to timeout. Can anyone help me out?
Sherlock and the Beast
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class test {
pu... |
Here's a merge sort I wrote trying to learn Scheme.
(define mergesort
(lambda (l cmp)
(define merge
(lambda (left right)
(cond
((null? left) right)
((null? right) left)
((cmp (car left) (car right)) (cons (car left) (merge (cdr left) right)))
(else (merge righ... |
I have just made a game called Hangman. I have added some stuff which people don't normally use, like cheat-code/s, time.sleep().
How can I improve this, in both readability and methodology?
import random
import time
hangman = (
"""
_________
|/
|
|
| ... |
In this program there is a single remote server which performs miscellaneous work. Because there is only one server, it seems like a singleton pattern could fit well.
The problem that a distributed program introduces is that every client will have its own version of a static variable. Therefore I have defined a basic ... |
I've implemented a small program in JavaScript to count the number of lines of a string of java source code.
This was done for one of the Code Kata exercise: http://codekata.com/kata/kata13-counting-code-lines/
Overall, the goal of this exercise is summarised as follow:
The mixture of line-based things (single line co... |
I'm trying to optimize this repetitive piece of code. I think I need to set subsection href as a variable and then figure out a way to merge the functions?
$(document).ready(function () {
$('#alphabetical').click(function () {
$('.subsection').attr('href', function () {
return this.href + '&sort... |
In order to learn Prolog, I have implemented the cat command in Prolog. I want to know if the code is idiomatic and what could be improved.
File args.pl:
:- module(args, [withFilesOrUserInput/2]).
withFilesOrUserInput(StreamFunction, []) :-
call(StreamFunction, user_input).
withFilesOrUserInput(StreamFunction, [F... |
I am new to async and was wondering if any improvement can be made to the solution I put together from scattered information on the web.
The following (working) code shows how a button press runs logic and if there are any errors they will appear in the returned task.Exception.Handle variable which I can check in my C... |
I am new to the world of jQuery plugins, I don't know why I didn't get into this sooner. What I have a working validator that validates bootstrap styled forms. What I have discovered is that the way it is set up causes error when there are more than one form on the page. I would like to know how to make it more efficie... |
I'm transforming this:
[["Apples", "fruitgroup", "123"], ["Bananas", "fruitgroup", "012"], ["Jumbo Jet", "planegroup", "99"], ["Crop duster", "planegroup", "40"], ["Melons", "fruitgroup", "55"]]
into this:
["Apples or Bananas or Melons [x]", "Jumbo Jet or Crop duster [x]"]
Because basically I have to group the child ... |
What my query is doing:
I have two SQL tables and I want to copy datarows from the one table to the other table. I am doing this for statistics. The source table includes all current member-sessions/logins and with my statistics table I also want to see member-logins of the past. Thus I want to store these data into my... |
I have this code, but it looks a bit verbose:
enum MonitoringMode
{
Seek,
Destroy
}
void ToggleMonitoringMode()
{
if (_monitoringMode == MonitoringMode.Seek)
_monitoringMode = MonitoringMode.Destroy;
else
if (_monitoringMode == MonitoringMode.Destroy)
_monitoringMode = MonitoringMod... |
As C does not have a native string type, I decided to try making a similar type. It's not perfect by any means, so I was coming here to see what I could do to improve it.
I have tested my code and it works; if I were to write 'User', the output would then be 'Hello User'
#include <stdio.h>
#include <stdlib.h>
#include ... |
My program is complete and working, but I would like second opinions on it. The program prompts the user to enter something like a phrase or some words. Then it will create an acronym of what was entered. What are some adjustments I can make to my program to make it more efficient?
#include <iostream>
#include <strin... |
This is a simulation attempt of an "old-style game", where a "car" (nothing more than a red rectangle) must dodge some "obstacles" (blue squares) falling from the upper edge of the frame. If an obstacle hits the car, the game stops.
The app works fine, but since this is my first project involving painting and moving ob... |
I am new to Angular. Am I following best practices here? I understand controllers should not do too much. My controller seems to have a lot of logic here. Can I do anything to improve it? It is just a basic ToDo App.
var app = angular.module('app', []);
app.controller('FirstCtrl', function($scope, todos){
$scope.t... |
I just started learning MIPS assembly at my university and I would like some feedback on this code. The program is Project Euler Problem #1, finding the sum of multiples of 3 or 5 less than 1000. It works but I am interested to hear what I could do to improve it (best practice, efficiency, etc). I found x86 solutions t... |
Applying a lot of unprecedented concepts here, it's a simple chat server capable of handling multiple clients, which are run through JavaFX, and have their individual threads instantiated and handled within the application thread (was more complex than anticipated).
The Chat Server:
import java.io.BufferedReader;
impor... |
I have the following Oracle SQL query to generate some system-stats. I am interested in making it a more efficient and readable query.
SELECT
SUM("Req Lines") as "Requisitions Created",
SUM("Approved Req") AS "Requisitions Approved",
SUM("Non Approved PO") AS "PO Started",
SUM("Approved PO") AS "PO... |
Since I couldn't find any good answers I made my own class called DuplicateDictionary for personal usage. I would like some tips to improve it.
public class DuplicateDictionary<TKey, TValue>: List<KeyValuePair<TKey, TValue>>
{
public DuplicateDictionary()
{
}
public DuplicateDictionary(List<KeyValuePa... |
Here is my second attempt at writing clean code for "Sherlock and Pairs" challenge. For my previous thread please look here: Calculate pairs in a Set ("Sherlock and Pairs" HackerRank challenge)
Problem statement:
Sherlock is given an array of N integers (A0,A1…AN−1) by Watson. Now
Watson asks Sherlock how many diffe... |
This code works just fine, but could obviously be more elegantly written.
The basic idea is to create an array of categories from a text input. The code splits up the text input by commas to create the array and trims away white space.
I considered using unshift to add the 'Inbox' default category to the beggining, b... |
My program is complete and running, but I would like second opinions on how I can make it more efficient. The program prompts the user for the message and the amount s/he would like to shift the letters. For the implementation part, is there another "faster" way to do it instead of having the if else if statements to r... |
I am using the java.awt.Rectangle class to construct subsets of a GEOTIFF file. In order to do this I would need to specify the x,y offsets, height and width of each subset image. In my particular case I would need to crop the original GEOTIFF image bottom to top. The java.awt.Rectangle class specifies that the origin ... |
I am developing an e-commerce site and am confused about this.
Customers come on the site and add some products to the cart.
Customers click on the checkout link if already logged in, then will go to the "thanks" page (this is your order number, total price, etc.).
I want to insert the total price into Order table.
<... |
I wrote an Array class with iterators:
#include <iostream>
using namespace std;
template <class T>
class Array
{
T* data;
int size;
public:
class mException { };
Array(int nsize=1)try:data(new T[nsize]),size(nsize)
{
}
catch(bad_alloc& r)
{
cout<< "Cant allocate";
throw;... |
Running on Cygwin, I cannot easily use perl -pi -e because it will always produce .bak files even though I don't want them. I wrote this script below to emulate perl -pi -e behavior and unlink the backup files after processing.
Also I wanted to simplify the call of the script. Instead of:
$ git ls-files | xargs perl -p... |
I need to call the function that will get the value of a datatable cell with the ColIndex, either a text (column name) or an integer (columnindex).
To avoid writing two functions that, I wrote this code:
Public Function DTableCellValue(ByRef RowData As DataRow, _
ByVal ColIndex As Ob... |
I've created code for a menu system that can show / hide menus and submenus. Now I wonder if the structure of the code is good enough or if you find something that can be done better?
var initExpanders = function () {
"use strict";
function lsTest(){
var test = 'localstoragetest';
try {
... |
The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.
Find the sum of all the primes below two million.
public class Java {
public static void main(String[] args) {
long start = System.nanoTime();
long sum = 0;
for (int i = 2; i < 2000000; i++) {
boolean isPrime = true;
if ((i % 2 == 0... |
I have a simple function that takes a string and reverses it:
def reverse(string):
begin = 0
end = len(string) - 1
strlist = [i for i in string]
while(begin < end):
temp = strlist[begin]
strlist[begin] = strlist[end]
strlist[end] = temp
begin += 1
end -= ... |
I have a system that accepts free text from users. This can either be plain text or a heavily limited subset of HTML. I've written the below with Html Agility Pack and Microsoft's AntiXss library. I have had to remove a few things from the below code which do things like whitespace normalization, punctuation normalizat... |
I am currently done with this little Rock, Paper, Scissors, Lizard, Spock game in JavaScript. The game is working fine, but I am not pleased with the code. Is there a way to refactor these if statements? I was thinking about ternary operators and I tried doing so but failed. This is basically my function based on which... |
I am new to Java Swing and have decided to create a calculator to learn some of the basic. I would like someone to look over my code to see if they can give me any improvements.
I have 6 classes and 2 interfaces. I have chosen to split the communication of both operators and digits. The mainframe is the controller and ... |
I been having discussion with colleagues recently about good use of matchers. Consider the following sample:
@RunWith(MockitoJUnitRunner.class)
public class LoginRestServiceImplTest {
@Mock
private LoginService loginService;
@InjectMocks
private LoginRestService loginRestService = new LoginRestServic... |
Shall I make a curry function this way, or is it best to avoid Function constructor in all means? What I want to know is if this is "bad practice" and how else currying can be done. For instance, one can bind arguments to a function with Function.bind, but it is more like a partial application thing. And will doing cur... |
I got to show the createdAt date in a message timeline, I tried to make a separate array only for dates, but don't know if it is the right path to follow. It seems to me that my workaround is too tricky.
I'd like to be sure that what I've done is not necessarily the right way, but at least it isn't a wrong way (Edison'... |
I want to construct a string from several substrings, each one of those with a different delimiter. If the string is present, the delimiter and the string should be added, if not, none of them should be added.
This is my current code that looks a bit dirty to me:
def my_join(major, minor, patch=None, pre_release=None,... |
I made a Tic Tac Toe game, but I think there's a lot of hard-coding and useless variables. Can you check it out and tell me what I can improve on? It works, but it has a couple of bugs.
#include <iostream>
#include <stdlib.h>
#include<windows.h>
#include<conio.h>
#include<time.h>
#include<iomanip>
using namespace std;... |
My Racetrack is just that. A Racetrack. You can't race it (yet) because I had trouble with collision detection, but I wanted to share it anyway.
It creates a base polygon by using numpy and shapely. matplotlib (together with descartes) does the plotting and cPickle is used to write states to file so the exact same trac... |
I'm trying to dive deeper into C#, and so I've been experimenting with some code. I'm creating a console application that shows the path of a projectile depending on the angle, and it works great! You can check it out here actually. It's not perfect, but I like it.
Is there a better way to use my for loops? I'm using 3... |
I needed a data structure to quickly find all previously inserted values, that have the given string as key or substring (full text search).
At first, I tried out some tree structures (infix trie/tree) and was shocked by the slow insertion time and memory usage.
That's when I developed the InfixDictionary<T>, which is ... |
Problem statement:
Write a function which returns the total number of combinations whose difference is k.
For example, 4 8 15 16 23 42 and the difference 7 has 2 pairs, 8, 15 and 16, 23.
I liked the Finding number of number pairs with given difference question so much (despite its brokenness) that not only did I rev... |
I have created an inventory that works via QR codes. Briefly: the QR code codes for an email with the book/student checking it out. The email is downloaded into R using the gmailR package (code not shown). The info from the email is taken and added to a table which is compared to a master table (the inventory) and the ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.