instruction stringlengths 71 71.9k |
|---|
My first Code Review post.
I'm up to a generic implementation of the A* search algorithm in Swift (for now, it's a single goal implementation).
Here's what's been coded so far:
// State : a protocole for states in the search space
protocol State : Equatable {
// successors() : returns an array of successors states... |
I have a cryptographic function with two 24 bit keys.
I have two blocks of input and two blocks of output, and want to brute force the keys using CUDA.
Overview:
The function is composed to two back-to-back 3 round substitution-permutation-networks with block size of 24 bits and sbox size of 4 bits.
Due to the low bl... |
I am writing a program that can implement algorithms to solve the TSP. My goals:
The solver can record every algorithm step, so that the whole solving process can be later visualised by charts or animations
It's easy to add new algorithm implementation
End user has full control over the simulation parameters
I tried ... |
I wrote some code to solve this problem https://www.hackerrank.com/challenges/string-o-permute which basically states: take an even length string and swap all the even indexed characters. For example the string "abcd" should become "badc". I'm looking for a general code review as I'm very new to F# and specifically I'd... |
I've created a basic cipher program that will turn your string into a Rot13 cipher. I'm pretty sure there are much easier ways to do this, so a little input on what I've done would be great:
What did I do well?
What can be done better?
Are there easier ways to do this?
using System;
namespace Rot13
{
class Ceas... |
I'm teaching myself Rust, and to do this I've written a toy register based virtual machine. I hope the code is easy to follow - I just want to know if there are any mistakes I am making with the language philosophy or if there are syntax tricks I could be using. For example, the program counter pc and the register fiel... |
Continuing the series of Code Explorer posts, here is the collection of view models for the tree nodes:
This is the interface for nodes with a declaration.
public interface ICodeExplorerDeclarationViewModel
{
Declaration Declaration { get; }
}
And here is the abstract view model they are all based on:
public abst... |
I have a component that I've used myself for quite some time, the short story is that it automagically implements a property change notification mechanism (very useful for implementing INotifyPropertyChanged for example, but can be useful in other ways as well).
There are other solutions available which use a similar t... |
This is my very first application written in Java and so I finalized it, solely because it occurred to be my thesis.
It is a very simple program that lists categories (Northwind database is used as a template db) and as you one-click one it lists ID, Name and Price of all the products in this category in a table.
dbu... |
The site should be accessible only to signed-in users. I'm making sure I publish and enable data manipulation to only those, but I wanna make sure even the app structure won't be visible.
What I did was creating an autorun that checks for changes in signed-in user and reloads the router. The router takes care of redire... |
I have written a program in x86 assembly (Intel syntax/MASM) that interprets brainfuck code that is fed to it via an interactive console and prints the final stack to stdout. Note that it does not include an implementation for the , command, but everything else has been implemented. The idea is that it presents the use... |
I have written a CSV parser to read in 12609000 lines of CSV data. Each line has 16 fields of both string and double type data. The following code takes about 40 seconds to parse the data. I would like to know if there is a better way of doing this which can make it even faster. I have seen recommendations to load all ... |
I have created a UI shown in the screenshot. I am initalizing too many JPanels within a panel in my code to achieve the UI which will lead to bad code design and slower performance.
Is there any good practices to follow in writing such a UI?
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Grid... |
Assuming everything else works as expected, is the following a correct - but not the most efficient way - of implementing Dijkstra algorithm? Because I have tested it on several examples and it gives correct result. But I can't imagine Dijkstra is that simple.
public static void FindShortestPath(Node source, Directed... |
Summary: Is my server handling every error and corner case possible? If not, what did I miss?
Details
I'm trying to write the most basic socket server I can, so I can learn TCP and the pitfalls of parsing network data. I'm also worried about security (DDOS mitigation) and making sure the server never panics (unless it ... |
Given constant external space (yes no HashMap), how would you improve the following code (code-wise or complexity-wise with stress on the latter) to find the majority element in an array?
/**
* Created by mona on 5/27/16.
*/
import java.util.Arrays;
public class FinaMajority {
public static int findMajority(int... |
I have written a simple JS module "loader" (loader is in quotes because it doesn't actually load the files) that is designed to resolve simple dependencies between modules. It is heavily inspired by module.js and takes some of it's design from it.
Here is the code itself:
(function() {
function create() {
var def... |
I wrote the following code for solving the Rod-Cutting Problem using dynamic programming:
Rod Cutting Problem: Given a rod of length n inches and an array of prices that contains prices of all pieces of size smaller than n. Determine the maximum value obtainable by cutting up the rod and selling the pieces and also fi... |
This is the first time I'm trying to use promises in JavaScript so I'm not sure if I have done it correctly, but it seems to work. The problem is that I have ended up with a "nested when" and it doesn't look that great. There probably is a nicer solution out there. I would really appreciate some feedback on how I can i... |
I am working on a genetic algorithm using the following code. The variable best in generateNewPopulation stores the best chromosomes from the previous generation and adds it without modification to the new generation. The problem is that if I allow crossover, the "best" changes it value to the best of the current gener... |
I have a list of factories. Each factory has an item of its own and a list of other items from competitors.
I need to sort the list of factories based on price of their items and also sort list of other items from competitors for each factory.
What I am doing require to sort collection of factories and loop through all... |
My task is to code something that prints out this:
This is what I have done so far.
diag matrix = diag2 [] [] matrix where
diag2 [] [] [] = []
diag2 xss [] (zs:zss) = diag2 [] (reverse $ zs:xss) zss
diag2 xss ((y:ys):yss) zss = y : diag2 (ys:xss) yss zs... |
I'm starting with PHP so I can save data to a MySQL database. I read a lot and it seems the "escape" strings is not so safe.
This is my code:
<?php
session_start();
date_default_timezone_set('America/Argentina');
require_once("config/db.php");
$link = mysqli_connect(DB_HOST, DB_USER, DB_PASS);
mysqli_select_db($link, ... |
I created my first java application for a college assignment. I tried my best to design my application using best practices of MVC design patterns. I have read about it on Stack Overflow and other sites. My question basically is: Do I follow the best practices? Every feedback is much appreciated. Below is my code.
View... |
In a txt file there are IDs and next to them there are their neighbours like this:
1 1
1 2
1 3
2 1
2 4
2 8
3 5
Using AVL trees I store the IDs in one AVL tree and for every ID in this AVL
I make another AVL tree in which I store its neighbours.In the end I make another txt file that in every line has an ID , i... |
I have this block of code which clearly looks like duplicate, but I don't know how to refactor.
float offsetDifference;
nfloat newLogoHeight;
nfloat newHeaderHeight;
nfloat newLogoWidth;
if (offset > _previousOffset)
{
offsetDifference = o... |
I'm an elixir beginner. I'm doing the word count exercise of exercism website. The word count exercise returns a map with the word as the key and the number of instances as value. The exercise excludes special characters, and ignores underscores. My code works, but I'm sure there is a way to make it cleaner. I've a... |
A few weeks ago I recall a HackerNews story (found it again: "I Don't Want to Hire You If You Can't Reverse a Binary Tree") about reversing a binary tree (with, as I remember it, the end goal being to test for symmetry by testing the reverse for equality with the original).
I started hacking this implementation up as ... |
I am wondering if my code is needlessly redundant. I noticed, when looking over my code, that I had a unnecessary variable and if statement. Both Fire() methods achieve the desired result without error (from what I have seen). To me, the redundant Fire() method reads a lot nicer and is my preferable method but I'm just... |
I'm looking for input, advice, criticism. This is my first helper class. While use of mailto URLs should most often be trivial, I have a real world need to send to multiple recipients and with a body of text something more than just a one liner. Doing so gets sticky and there are some pitfalls with reserved characters,... |
I've created a project on Khan Academy as part of the Natural Simulations course on random walks.
This project is in JavaScript, using the Processing.JS library, slightly modified by Khan Academy.
(In the main, the inclusion of the Processing.JS library offers a few functions for drawing on a canvas. The majority of my... |
Solution:
public class RemoveDuplicateInString {
public void removeDuplicate(String s){
System.out.println("Before::"+s);
int len = s.length();
for(int i=0;i<len-1;i++){
char c = s.charAt(i);
String preString = s.substring(0,i+1);
String temp = s.substrin... |
(See also Finding shortest paths in a Wikipedia article graph using Java - second attempt.)
I have this sort of a web crawler that asks for two (English) Wikipedia article titles (the source and the target), and proceeds to compute the shortest path between the two:
package net.coderodde.wikipedia.sp;
import com.googl... |
Problem Statement
In a school, chocolate bars have to be distributed to children waiting
in a queue. Each Chocolate bar is rectangular in shape. Consider its
side lengths are integer values.
The distribution procedure is as follows:
If a bar is not square in shape, then the largest possible square piece of Chocol... |
This program prints odd numbers by thread1 and even numbers by thread2 sequentially. Can this code be optimized or made more efficient?
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
pthread_mutex_t count_mutex = PTHREAD_MUTEX_INITIALIZER;
pthread_cond_t condition_var = PTHREAD_COND_INITIALIZER;
void *fu... |
I have been learning common lisp and am a newbie, using the great book Practical Common Lisp. There is a once-only macro in the book that I spent a lot of time figuring out how it works. Even after I figured out how it works, I still have to look at it and think for a while every time I come across it.
I tried to write... |
I have some buttons in my class that show or hide two views (by setting their alpha property to either 0 or 1) when the user taps on them. I have written a function that uses the tag property of the sender of the button (which is passed to the function by default) to identify which view to show or hide:
@IBAction func ... |
The number is ranging from 1 to 999999999.
public class ConvertIntegertoEnglish {
private String getCountSuffix(int value){
String word = "";
switch(value){
case 3:
word = "Hundred "; return word;
case 4:
word = "Thousand "; return word;
case 5:
... |
Whether based on MVar or TVar, async implementation are always based on operation on some underlying monad IO and STM.
Making Async a monad on its own, as in F# async computation builder, if done in a naïve way require littering with unsafePerformIO which does not feel very haskellish.
module Async2(Async, async, wait)... |
I am a beginner in Python and I wanted to see if I could get some feedback on my simple Rock, Paper, Scissors game. I do have previous experience in programming, as I started learning a few years ago but got happy feet and moved through the "basics" for a lot of different languages.
With that said, I plan on sticking w... |
GitHub repo.
main.c
#include <stdio.h>
#include "level.h"
static void flush_stdin(void);
int main()
{
int level;
puts("Enter a negative integer to exit.");
for (;;)
{
printf("Enter level: ");
if (scanf("%d", &level) != 1)
{
puts("Please try again.");
f... |
I started learning C++ a few days ago, and this is my first full program. It takes in words until an end-of-file character prompt is given, and then outputs which of those words are palindromes and the longest palindrome of those words.
I want to know if my evaluation for whether each string is a palindrome is acceptab... |
Many implementations of Sieve of Eratosthenes (used to find prime numbers up to a given n) use a temporary mutable array to keep track of which numbers are composites. I'm looking to write a purely functional version that has the same runtime complexity:
(define (primes-up-to n)
(cons 2 (unfold null?
... |
Since I've never done any performance programming (Aside from the better choices such as array vs list etc. The real basics.), I should probably read up on it. But I had to start somewhere, so, someone I know - which is a much better programmer than I am - tasked me with making this "assignment":
You are given the tot... |
I have created an Electron Application with a JavaScript/NodeJS Backdoor and a Ruby command-line listener.
I created this program for remote administration of my home computer securely using a new technology (WebSockets) which I found very interesting.
The program has two parts:
The Electron application written in Ja... |
I am working on a Ruby gem to pull data from the Wikidata API. The data is deeply nested, as it contains a lot of repetition.
I have written a piece of Ruby (sans Rails) code that enables an array of hashes to be merged together, with any duplicate key-value pairs being stored as an array under the same key.
For examp... |
I'm a newbie to F# and so I've written a small extension method library to practice the language. The extension method attempts to determine if a url string is for an image. I wrote the code as an extension method so that it can be used as an extension or static method in other .net languages, namely C#.
The code... |
I'm making a neural network that comprises five populations of feature-selective neurons and one population of non-selective neurons. Each neuron in this network receives connections from
c * f * N_E randomly selected neurons from each of the selective populations
c * (1 - f * p) * N_E randomly selected non-selective... |
In this example, I am only looking for the first duplicate - curious if this logic in for loop (take from the top, evaluate, put on the bottom) pattern has a standard form
function findOneDupe(input){
var b = input.split(/\s|\n/).map(Number);
b.shift();
for (var i=0;i<b.length;i++){
var e = b.shift();
if ... |
The following Bash script takes a single parameter (the PAN) and exits with 1 if the PAN does not satisfy a LUHN check.
#!/bin/bash
pan=$1
panlen=${#pan}
for i in $(seq $((panlen - 1)) -1 0); do
digit=${pan:$i:1}
if [ $(((panlen-i) % 2)) -eq 0 ]; then
#even
((digit*=2))
[ ${#digit} -eq 2 ] && digi... |
The problem is that I had an interview for a gaming company and I had to write a prototype of a Match Three style game. The time line was 3 days. I made the code in about 2 days and sent it to them.
Then I had a rejection and a comment that my code has "many problems with performance, basic programmers mistakes and pos... |
I am trying to prototype a simple structure for a Web crawler in Java. Until now the prototype is just trying to do the below:
Initialize a Queue with list of starting URLs
Take out a URL from Queue and submit to a new Thread
Do some work and then add that URL to a Set of already visited URLs
For the Queue of startin... |
A couple of weeks ago a company sent me this coding challenge:
Please write a PHP web application and send it back to me as zip file:
Which waits for a user action, like clicking buttons. According to these actions some data (see further below) should be:
either shown nicely formatted on the screen
or downloaded as ... |
Requirements
A function is needed, that is able to parse a list of symbols with the following rules:
Symbols may be associated with numbers or not.
Numbers are defined by a comma separed list behind the symbol.
Numbers may be defined as range (e.g. 3-7 or also 7-3).
Whitespaces and invalid tokens should be ignored a... |
To get familiar with the Rust language I've decided to implement the method of Sieve of Eratosthenes to find primes up to a number N.
I have created the following code that both prints the prime number and whether it is prime in tabular format and prints a vector consisting of the prime numbers.
As additional library I... |
If I have this simple structure:
$ tree
.
└── project
├── __init__.py
└── my_script.py
where I want to define __version__ in __init__.py (this allows setup.py, in the parent directory, to import project.__version__):
$ cat __init__.py
# -*- coding: utf-8 -*-
__version__ = "0.1"
Now, I also want to use the va... |
I have this menu in jQuery that works perfectly, but I think it would be better if, instead of using class="btn-accordion" for each li, I just had a single class="accordion-menu".
Is that possible or is the code OK?
my html:
<div class="accordion-menu">
<ul class="" role="tabpanel">
<li class="btn-accordion i... |
This is a Windows Forms application that adds JavaScripts to PDF files. It supports multiple files at the same time. Right now, the only supported script is a "time-stamp on print" script, but any others I add in the future would work exactly the same in principle.
My company uses the "time-stamp on print" script for t... |
I have following problem: My server (ASP.MVC WebAPI) is tracking, when client application ("Agent") is on-line. It's storing this inf on following table:
+-------+-------------------------------+-----+
|AgentId| Date |State|
+-------+-------------------------------+-----+
| 1 | 30 may 2016 ... |
I am trying to fill a hashtable with LicenseID and FullName when user first logs in. I don't have access to the Licenses database right now. So "Context" is a place holder. I am at loss if what I am doing is kosher.
On load of first MVC C# View:
MySingleton.GetInstance().BuildAllGrowers();
Here is MySingleton class
... |
There are two methods, hash1 and hash2, that return hashes or nil. The hashes have the same keys. I want to merge them with their mean value only if both methods have hashes.
(I added Array#mean to calculate the average value of an array).
def merged_hashes
return if hash1.nil? && hash2.nil?
return hash2 if has... |
I recently discovered a hugely inefficient portion of code in my program, and have gone about rewriting it. I am however, not quite sure if the rewritten program actually does exactly what I want, due to its (relative) mathematical complexity. I am especially uncertain about how this new code will handle changes of the... |
I have a very long sequence of letters (>20000 elements long). I want to permute them so that I have another sequence using the same letters but in a different order but still with the property of no repeats. e.g. ABABABA does not have repeats, but ABCDEEABCDE does as E is repeating itself in the middle.
I cannot acc... |
I'm reading the K&R book and I'm interested in a program which finds the longest line on the input. I've written the same code as in the book, but I wanted to do it myself. I tried to write my own code to do same thing. I think it's working, but my question is whether my code is "good" or if it's written in a "bad way"... |
Here are two implementation of a stack that does Push, Pop and Median in O(1). Invite comments on complexity and betterment.
Option - 1
public class MedianStack {
private Deque<Integer> stack;
private PriorityQueue<Integer> minHeap;
private PriorityQueue<Integer> maxHeap;
public MedianStack(){
... |
I need some suggestions on my reimplementation of a doubly linked list with smart pointers since I'm new to smart pointers in C++.
I read some docs on smart pointers and found out there are shared_ptr<Obj>, unique_ptr<Obj> and weak_ptr<Obj>. I only use shared_ptr<Obj> in my current code, but I'm not sure how to use uni... |
This a solution to the shortest bitonic tour using dynamic programming. Bitonic tour starts at the leftmost point then goes strictly rightward to the rightmost point and finally strictly leftward to the starting point. The complexity of this algorithm is . I also use sfml to draw it (Just started using it, this part is... |
I am a self - taught coder, and have been learning Java / C# for the last 2 1/2 years (inconsistently).
I have recently created a snake game in Java with the help of an online tutorial. I have rearranged the program into separate classes & methods. I am skeptical on how good of a programmer I am, and I code messy.
I do... |
Wrote a practice code for reversing a string say.
Input = "This is funny"
Expected output = "ynnuf si siht"
This code works for me. Want to know your comments and a better optimised way to perform this.
void reverse_string(std::string input)
{
int N = input.length();
char buffer[100];
char* ptr1;
... |
I had previously submitted a tic tac toe code. I followed some of the changes suggested. This is my new code.
var playerSym;
var computerSym;
var turnCount = 0;
var playerWin = 0;
var compWin = 0;
var whoseTurn;
var grid = [];
var winFlag = false;
var playerScore = 0;
var compScore = 0;
var winningLine;
var emptyBoxes... |
I wrote the following function to find the longest increasing sub-sequence in an array (tuple, it doesn't work for a list since a list is mutable and it stores the results in a dictionary.). It uses Top Down dynamic programming approach.
def LIS(seq, memo={}):
if len(seq) == 1:
return seq
elif seq ... |
I know this is a long code and hard to read but when i started working on this it was just a few if-s, and as time passed i added more and more and came to this. Tried refactoring it by my self and anything i tried to do had no effect on code. Switch statements don't work here( doesn't lower amount of lines needed for ... |
The past few weeks I've been trying to grasp on nearly any Design Pattern ever invented, but the repository pattern is one I could understand and implement it myself in my project. My application uses the MVC pattern where I've got the "V" and the "C" part covered in a very basic way, and I want to get rid of a single ... |
Recently I did an exercise for a interview pre-screening, but was not selected. They did not give much detailed feedback apart from "the code was not up to what they wanted".
It would be really helpful to understand as to whether the code written is up to production standards and what is it that I could be missing.
He... |
I'm getting an array and I needed to find a duplicate ID inside:
var aDuplicateId = [];
//get the duplicated configuration indexs
for (var i = 0; i < aConfigurations.length; i++) {
//in case the index is the duplicate array skip
if (aDuplicateId.indexOf(i) >= 0) {... |
Is it possible to make this cleaner / more efficient? I know that this is probably not the best way to do this and probably could be made better but I cannot figure out how I do that.
Basically, a number is given which is then compared to the numbers in Num[] and then returns a color based on that comparison.
private C... |
Basically, all I have to do is read some xml from a file. And I have a working solution, although I am not sure that it is the best way of going about doing things, as I have only recently started working with xml. Any advice on how I could improve the following?
[XmlRoot("iosLayout")]
public class iosLayoutXml
{
[... |
This is the problem:
Calculate
$$\sum_{i=2}^{10^8} s(i)$$
where \$s(n)\$ is the smallest \$m\$ such that \$n\$ divides \$m!\$.
Quite mathematical, I've found a better way than brute force by using largest prime factor and greatest common divisor. It works fine when n = 100 but still very slow when n gets larger and f... |
I was advised by a Reddit user to get my code reviewed on this site.
The complete code is on GitHub.
# Monopoly Simulator
# http://img.thesun.co.uk/aidemitlum/archive/01771/Monopoly2_1771742a.jpg
from random import randint
piece = 0
jail = 0
iteration = 0
brown1 = 0
brown2 = 0
light_blue1 = 0
light_blue2 = 0
light_... |
I am implementing a music player for Windows 10, and I am in a bit of a pickle at the library phase.
I am scanning for all the files in a music library (plus optional folders the user selects) and I need to get their tags (only need the title and artist; don't need complex details).
The problem is performance. Getting ... |
I wrote the following code:
var xmlArray = from m in (from row in data select row.Mitarbeiter).Distinct()
select "<Value Type='Text'>" + m + "</Value>";
var xml = string.Join("",xmlArray);
Then I noticed there are two iteration (two from) and also the Distinct() and I rewrote it using a foreach:
var mit... |
I have just finished working on a problem on hackerrank dealing with time conversion in C++.
I'm still fairly new to programming as I only have a few semesters of programming classes under my belt and had a pretty challenging time with this program.
Below is a link to the problem itself and my code.
I solved the prob... |
I want to find common items between two collection, and set values from one collection to another collection. I am aware of similar posts on the web, but they are different from this post. I want to know if there is a better algorithm or method than my current code below
class Job
{
public Job(int id)
{
... |
The Ruby on Rails framework doesn't allow you to validate enums submitted through a form in any sane manner. Evidently, enums are meant to be used to maintain internal application state, and are not supposed to be user-facing. Well, in my case it doesn't matter too much, but I still want validations *just in case*.
Her... |
This is the first time I've tried this. I'd like some feedback on how I did, including any bad practice warnings. For example is it a really bad idea to allow the code to recreate the table if it doesn't "think" it exists? Would it be better to simply create the table once in a different file?
<?php
/*
Database and ma... |
I'm trying to get better in Python and decided to rewrite my dice roller in Perl into Python.
#!/usr/bin/env python
"""roll D&D dice"""
from sys import argv
from random import randrange
import re
if len(argv) < 2:
raise ValueError("args are dice in D&D format like 2d6")
for roll in argv[1:]:
matched = re.mat... |
I've created a simple hangman solver and although I'd consider myself proficient in webdev I am by no means an expert. The trick with this is that since HTTP is stateless, I can't really think of a better way to look words up than to start from scratch each time (and lookup is performed with ajax EVERY time the input c... |
I would like to hear feedback from an interviewer's perspective on how to improve the following code:
from collections import Counter
def word_map(string):
word_dict = {}
stop_word_file=open("stopwords.txt", "r")
stop_words =stop_word_file.read().split()
for word in string.split():
word = filte... |
I already know how to merge two linked list, but I needed to code a function that'll merge three already sorted linked lists into one.
I wrote a code and it is working fine, it takes care of null lists and so. I just don't know if it's efficient enough. What do you think? How can I improve this code?
typedef struct cli... |
I have written [PHP code][ to upload image/s to server.
(To see the result, open the JavaScript console of your browser, look at the Network tab or the Console tab.)
The code is also available and runnable on paste.ofcode.org.
(Upload images)
I would like to know if this code is secure for uploading valid images.
<?php... |
I'm trying to speed this code up for larger values of N. Any suggestions?
I'd like to stick to this implementation and not move on to something more complex like numpy or sieves.
Is there any low hanging performance I'm missing?
import time
start = time.clock()
def prime(num, divs):
prev = 1
if divs:
... |
I watched this video from The Unqualified Engineer on YouTube and tried out the challenge. The challenge (or interview question) is to build a generator that returns all the permutations of the positive integers up to \$n\$ (that is, \$1,2,3,\ldots,n\$).
I know about itertools.permutations but want to implement it myse... |
Edit: After reading Gareth's answer I have pushed an updated version of the code to github.
I needed to shuffle cells from specific columns in several CSV files. One of the requirements was to be able to do derangement (shuffling that leaves no element in its original place), I read about Sattolo's algorithm.
So I sta... |
I'm just starting out with code. I created a very basic JavaScript calculator.
While writing, I couldn't help but think that there must be easier, faster and less redundant ways to write this. For example, when I have to update the display, I have to call the refreshScreen function, which then takes the previous HTML,... |
Just looking for some constructive (harsh) criticism of a project I've completed and handed in. This is a theoretical implementation of the system, specifically has a simplified registration number and a simplified driving licence number generator. I've added in the other classes for clarity (and criticism is welcome f... |
I'm looking for a structure to store large amounts of strings (5k to 100k) and then test for existence of new strings against the previous inserted data, in the least possible amount of time (memory is mostly irrelevant). The structure would first be fully loaded at the program start, without any queries. After the bui... |
A friend and I watched most of the thenewboston syntax videos for Python 3 and spent 2 hours attempting to piece together our first program / generic text adventure. First experience with coding.
I'm looking for feedback on silly code and poor conventions.
Pastebin
class Erdrick():
exp = 0
level = 1
levelu... |
After learning about linked list implementations of a queue I was asked to try a resizing array implementation. I'm looking for constructive criticism.
import java.util.NoSuchElementException;
/**
* ResizingQueue - Resizing Array Implementation.
*
* @author Rocky
* @version 2016-05-31
*/
public class ResizingQue... |
This code checks value's type and cast it into appropriate type, then puts it into a javax.jcr.Node.
The checking looks long and boring. Is there a way to refactor it? I'm using Java 7.
/**
* Set node's property.
*/
public static void setProperty(Node node, String propertyName, Object propertyValue) throws Repositor... |
The Longest Palindromic Substring challenge from InterviewBit:
Given a string S, find the longest palindromic substring in S.
where a "substring" must be contiguous, and in case of ties the first such substring should be returned.
Example:
Input : "aaaabaaa"
Output : "aaabaaa"
My code:
class Solution:
# @param... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.