instruction stringlengths 71 71.9k |
|---|
I've got pretty straight forward scenario. I've got a class called FileInformationExtractor and method GetFilesInformation that takes directory path to find files within it and yields specific information about each of them.
Exceptions I consider here that should be handled are IOException and UnauthorizedAccessExcepti... |
I have a RecyclerView that works and everything, and this is how I coded it:
public class RazzleRecyclerViewAdapter extends RecyclerView.Adapter<RazzleRecyclerViewAdapter.RecyclerViewHolder> {
private List<Razzle> mRazzleList;
private Context mContext;
private SelectRazzleRowListener mSelectRazzleRowListene... |
I made this utility class to convert Closeable instances to AutoCloseable, so that I can make use of the try-with-resource exception handling mechanism of Java7. This is mainly useful for code which can not be altered.
public class AutoClose<T extends Closeable> implements AutoCloseable, Closeable {
public final T... |
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 bar is not square in shape, then the largest possible square piece of Chocolate is... |
This program is supposed to calculate the mathemathical maximum of helpful flags you can have on the nth day, starting with 0 helpful flags, using the StackExchange system of gaining more possible flags, meaning every 10 helpful flags you gain one possible one, immediately.
#include <stdio.h>
// <summary>
// Small C p... |
the TotalSavings() function on the record below has a code smell that I can't exactly detail. Is there a more readable alternative for implementing this function on a record type?
type ProvidersCharged = ProvidersCharged of decimal
type InsuranceSavings = InsuranceSavings of decimal
type ClaimsSummary =
{ Claims:... |
I have a list of objects with a string (name) and a local date (date of deletion).
I wish to implement uniqueness on these objects based on:
If two objects have the same name, then I wish the one with no date
of deletion to have priority.
If two objects have the same name, and a date of deletion, then I wish the one ... |
Description:
The goal in this problem is to find the minimum number of coins needed
to change the input value (an integer) into coins with denominations 1,
5, and 10
The input consists of a single integer m.
1≤m≤103
Output the minimum number of coins with denominations 1, 5, 10 that changes m.
Code:
import java.util.... |
I am working on wavelet decomposition and found a formula for it and wrote it by myself for computation.
The formula is:
$$I_{LH}(i,j) = \sum_{p=1}^{N_L} \sum_{q=1}^{N_H}\ L(p)\ H(q)\ I(i+p, j+q)$$
This is LH filtered and I do it for LL, LH, HL and HH so i get 4 images.
Can someone check the for loop in it and help me ... |
I have been working on sorting a file in-place with heapsort. I'm very glad it is working. But the time it takes is just too much. So I was wondering on how I could improve it.
Here are my requirements:
The file consists of 14B index entries. One index entry consists of 8B of the actual index and 6B of offset. I want ... |
This works fine, but obviously it's messy and I'm thinking there has to be a better way to do this. Having to constantly remember to flip the bool back is a pain, is there anything else I can do here? I take it SpriteKit itself doesn't have any convenience method for calling something only once for example.
func updat... |
I'm interested in parsing and extracting the IDs found in a document. The IDs are found throughout the document in the this format:
IDStart=1FG3392MQ9&IDEnd
The "1FG3392MQ9" is an example of such an ID (it will always appear between the IDStart and IDEnd tokens as in the above example). There will be text before and... |
I have created a script to generate 5 random codes, check if any one of them exists in the database, and if not, insert the record. The script will throw an exception if a single code could not be generated.
The rationale is that of an arbitrary 5 random codes, at least one should be unique. If not, throw an exceptio... |
I wrote a generic binary search routine in C++ for ranges that are specified by random access iterators. In case the user inputs a range with non-random access iterators, an exception will be thrown. My code is below:
binary_search.h
#ifndef CODERODDE_BINARY_SEARCH_H
#define CODERODDE_BINARY_SEARCH_H
#include <iterato... |
I am working on understanding Railway Oriented Programming (Scott Wlaschin style) in F#. In my example I want to create a pipeline which does some calculation, applies two different functions to the output of that initial calculation, then hands off a tuple of its results to a final function.
In real code the 'initial... |
I'm creating a GUI with tkinter that will handle starting/stopping/and logging events for a web-scraper (scraper not created yet).
The current code is working... but I've been gathering my information from so many different sources I'm sort of lost in the mire on how to improve it. The biggest problem right now is that... |
Due to severe code-evolution i will repost this question here! The original can be found here : Kattis Challenge - Animal Classification
I'm new to competitive programming and C++ in general. I have solved
the Kattis Animal Classification challenge. We are given two
classification trees, each represented using nes... |
The reason this was made was because of a combination of things. Firstly, it was made for me to get more acquainted with some ECMA2016 syntax. Secondly, this is a useful utility class when working with grids of undefined width and height, including negative points (I couldn't easily find some already made). Besides tha... |
In my Tkinter projects I almost always end up with __init__() methods that look like this:
import tkinter as tk
from .common import ConfigPageFrame
class SystemInformationPageFrame(ConfigPageFrame):
def __init__(self, parent, callback_dict):
super().__init__(parent)
self.columnconfigure(0, weight... |
I have a variety of images that will be used in a style intended to mimic a dot-matrix LCD.
In a previous version, I rendered these images using a program and essentially ended up with a duplicate of the entire image library (quite large!) whereas for this "rebooted" version I want to take advantage of newer technologi... |
I have a machine that is being controlled by an Arduino. If I send the machine the command '9' it will send back JSON with some sensor temperatures in the format {"temperatures":{"bean_temp":110.75,"env_temp":98.15}}.
I am exposing a function called getTemperatures() that I currently call from elsewhere every 1000ms. ... |
I personally don't like the boilerplate of most __init__ methods:
self.a = a
self.b = b
...
So I thought this would be a nice opportunity to learn a bit more about decorators. As this is my first attempt on a class decorator I'm sure there is a lot to improve so fire away:
Implementation
from collections import namedt... |
I am completely new to unit testing. I read this chapter in Dive Into Python 3, and decided to give it a try on a basic data structure: a stack.
Here is the stack code (taken from "Problem Solving with Algorithms and Data Structures using Python"):
class Stack:
def __init__(self):
self.items = []
de... |
I'm diving into the world of nodejs and mongo. I am playing around with a simple app that uses MongooseJS to talk to Mongo. I have been looking at examples and some GitHub projects for references, but the pattern seems very sloppy to me. Is this approach considered normal, or is there a better way?
Here is a sample fro... |
This class is used to create sets out of nodes to from a graph-like structure (or grouping since I remove most of the normal graph structure and all child nodes have the same parent).
Is there anything I can do to improve the design of this class? Is the use of static methods here appropriate?
class UnionFind(object):
... |
I need an example on writing this code with range based loops:
int pListPet[2] = {34001, 34051};
int pListGlobal[] = {9001, 9002, 9003, 9004, 9005, 9006, 20011, 20091, 20092, 20093, 20094, 20095, 30000};
const char* strMapListGlobal[] = {"string1" , "string2"};
const char* strMapEventOx = "string3"; ... |
In my quest to better myself, it's time for the C++ version of my StreamingPin class, and all relevant helper classes.
The F# version: Streaming a Pin functionally(ish)
The C# version: Validating a StreamingPin
The F# version has no answers (yet) but I'm posting the C++ version as F# is a pretty inactive language here... |
Challenge
Given two strings, determine if the second string is a rotation of the first.
Specifications
The first argument is a path to a file.
The file contains multiple lines.
Each line is a test case represented by two comma separated strings.
For each test case print out True/False if the second string is a rotatio... |
I'm working on an A* pathfinding algorithm to solve a programming problem, and part of the constraint is the runtime. I need to find a path in a 2D grid with blocked or non-blocked tiles. You can't move diagonally.
I have succeeded to make a working prototype of the function which can and will solve the problems encoun... |
Problem : https://www.hackerrank.com/challenges/down-to-zero-ii
You are given queries. Each query consists of a single number N. You can perform 2 operations on N in each move.
If N=a*b (a!=1,b!=1),we can change N= max(a,b) or decrease the value of N by 1.
Determine the minimum number of moves required to reduce th... |
On many articles and blogs, I have read that exceptions should not decide flow of your code.
I have wrote the following code using one thread:
public void run() {
while (true) {
if (jobQueue.size() != 0) {
Job job =
(Job) jobQueue.pop();
try {
... |
I am rather new in GUI programming and multi-threading apps. It is just a serial port monitor which plot serial data via pyqtgraph. There are two curves on the first plot (a and b) and one curve on the second plot (c which is (a-a_prevous)/(b-b_prevous)). How can I improve this code in general? I use Python3.5.
from Py... |
I have a function that I use to convert a list of dictionaries into a list of tuples, similar to itertools.groupby() would do in an ideal world. The goal is to make a list of {unique-dict} => [list of values]. I'm having a hard time explaining it, so I hope the example makes it clear.
I couldn't find a thing on goog... |
I have written a shell script to manage the tcpdump pcap logs and syslog files in my Linux board, so as to maintain the disk usage to maximum of 70%.
The script checks for the disk usage every minute and as soon as the disk goes higher than 70%, it deletes all the oldest files that are not in use until the disk usage ... |
In trying to compute permutations of a given String, what can I do to further improve the code below for memory and/or time efficiency?
import java.util.ArrayList;
import java.util.List;
public class Main {
public static void main(String[] args) {
permutateString("ABC");
}
private static void per... |
I'm implementing the Hotel Price List API from Skyscanner. This requires a first call to the service to implement a session followed by 1 or more calls to the service to get the actual results. I've used curl to implement this and got a working solution, I just wonder if this solution can be improved.
What I have:
pub... |
I have written a function to selectively extract data from a file.
I want to be able to extract only from a certain line and only given rows.
Would convert this function into a generator improve the overhead when I need to process large files?
import itertools
import csv
def data_extraction(filename,start_line,lenght,... |
I have developed a Tender management System sort of code for one of my client. This is the piece of code :
try {
Connection con = Mycon.getConnection();
PreparedStatement ps = con.prepareStatement("TRUNCATE tempcalcplan");
ps.executeUpdate();
ps.clearBatch();
... |
I'm writing a simple database class so I could use it in my future projects. It is based on some Codeigniter database methods, but my implementation, so if you could review this, that would be cool. It is not finished yet, but I want to remove all bad code early on.
<?php
class Database {
private static $instanc... |
Attempting to learn dynamic programming, it seems like the algorithm works. I'm looking to make sure the algorithm is correct (and actually uses dynamic programming correctly) and for pointers on ways to clean up the code.
The algorithm creates a meta data table that has the element's value, the length of its longest s... |
My company is designing a new site, and because I'm currently on bench I've been tasked with writing any PHP required. Pretty simple stuff, just a contact form and a resume upload page, both using a form to email the details to management. No database, no SQL, no business logic. The designer had already built the bul... |
I have an application that basically exists as a map and some controls. The controls change the look and feel of the map. I have a slider which is used to change the brightness, for example. At the moment there is only one map but more might be added in future. This seems to me like a good situation for observer patter... |
This is a followup of the last review to comply with meta's rules.
In the last, I posted a small library called colorprint and got some helpful pointers from chux in his answer.
colorprint.c
#include "colorprint.h"
#include <stdio.h>
#include <string.h>
#define CP_BUFSZ ((3 * 2) + (2 * (CP_FX_END - 1)) + 1)
enum v... |
I wrote a simple room booking system to get to know more about C++ and OOP. It simply stores rooms/labs/lecture halls with name, position, doors and possibly more details and can be booked/unbooked. features include dynamically adding/removing rooms, getting specific query rooms and summarizing the details. The C++ cod... |
I have taken my original code from here and turned it into an es6 version of the same game.
Any code review and critiques are useful.
Side note: "Bankrupt" and "Lose a Turn" do not do anything right now as it is a non-multiplayer game right now and I do not think it adds anything to the dynamic, but the wheel I have ha... |
I wrote this implementation of a singly linked list but I don't find my code enough simple and compact. Could you help me to simplify it?
Includes
#include <exception>
#include <iostream>
Structure of data elements
template<typename T>
struct Link {
T val;
Link<T>* next;
};
Class of singly linked list
templat... |
I have a function that returns postal codes between the ones given. It works but I feel like I made this over-complicated and there's easy way to make it more simple but I have no idea how.
Inputs are two strings that represents postal codes of my country. They are in the format 'XX-XXX' where X is [0-9]. The task is t... |
I'm writing wrapper for REST API of a service. In my wrapper I have quite simple method:
public List<string> GetAvailableSources()
{
var request = new RestRequest($"session/{Id}");
var sessionProto = _client.Execute<SessionPrototype>(request);
return sessionProto.Data.InstalledSources;
}
It's really simple... |
This is my first ever program in C and I was just tinkering around with this idea, as I'm on a music based course and the synth plugins all use milliseconds as its time.
Any improvements to make it more efficient or less dependant with a little explanation would be really appreciated.
/* declarations */
int crotchet(i... |
I worked on this for a software engineer interview as the take home challenge. The company came back with this constructive feedback:
You made a slight mistake in ace handling that led to the inability
to handle multiple aces
You hard-coded global variables for player1 and player2 state (why is this bad?)
There wa... |
I'm working on a Xamarin application and I'm presenting a list of objects in a TableView that are grouped by a specific property of the object.
The property is a date. For each distinct date, I am creating a table section with a header containing said date. Below is the working code to accomplish this, but It's not ver... |
This is my attempted solution to exercise 2.4 in Cracking the Coding Interview.
The problem statement is:
Write code to partition a linked list around a value x such that all nodes less than x come before all nodes greater than or equal to x.
Example:
Input: \$ 3 \rightarrow 5 \rightarrow 8 \rightarrow 5 \rightarrow... |
I have recently come to use VBA class modules in my code.
Based in part on an answer on Stack Overflow, I bought VBA Developer's Handbook and Professional Excel Development, but it took me a long time to 'get' classes (though I still have a long way to go).
I wrote myself a GetExternalData class, as one of the very com... |
I want to learn how to write good code. Starting off with simple programs for now. So any suggestions regarding style, readability or more efficient ways of implementation, etc. would really be appreciated!
#include <algorithm>
#include <iostream>
using namespace std;
int main(int argc, char** argv)
{
bool running ... |
Here is the task:
For an integer n, return a list of the k length integers sequences whose product is larger than n but as close to n as possible (i.e. smallest larger than n number), and whose largest member is the smallest possible. For each sequence length k, there is one such sequence, and we want to have the seque... |
This is the TicTacToe.java program that I've coded. How can I make this code more like a production type of code (except for Lack of Comments Part)?
Requirements: Design the basic Tic Tac Toe game
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
interface MoveMethod
{
pu... |
I want to improve my C++ skills ( or learn it properly ) so I decided to work on some algorithms for maze generation.
Here is the gist:
https://gist.github.com/imerovic/0cb7396bb67b345235054b5027d2eadf
I have some doubts about memory management and if I'm using pointers properly.
Please review it because I wanna know ... |
I'd like to improve my algo to find out the (sub)sum of consecutive values from the list. The function will return match as a double index, where the first value is the starting point of values, and the second value is the endpoint of values, where the searched sum can be generated.
// f=find sum value, a=list of value... |
I'm using the following function to enable dragging on an SVG group.
var dragcontainer = d3.drag()
.on("start", function () { })
.on("drag", function (d, i) {
this.x = this.x || 0;
this.y = this.y || 0;
... |
I'm trying to implement LSD radix sort in python, but my code used 4 loop, is there any way I can do it in three or less?
Here is the 4 loops:
First loop iterate through the input list, convert it to desired radix, and change each number to a reversed list, like so:
123 --> 173 --> [3, 7, 1] #radix == 8
Second loop i... |
The following class is a sort of "smart pointer" that can be used for automatically releasing pointers:
template <class Type>
class Releaser {
public:
Releaser(std::function<void(Type *)> function = [](Type *value) {
value->Release();
});
~Releaser();
Type *operator->();
Type &operator*();
Type *get();... |
I have 3 inputs, when I press enter on them same operations happend.
This is my code
How would you do this better?
var __this = this;
var a = document.getElementById("content").getElementsByTagName("more-content")[0].getElementsByTagName("input")[0];
var b = document.getElementById("content").getElementsBy... |
I've been playing around with generators, generics and extension methods in C# (5.0) and wanted to create an extension method for IEnumerable, which would append another IEnumerable to it and allow a limit to be put on the whole thing.
The way this differs from just using Concat() and then Take() is that instead of pas... |
I am making my own optical encoders. Each of them follows the exact same structure, so I figured I'd lump all the encoder processing in a class, StepCounter. However, when I directly attach an interrupt to a member function, I get
cannot convert 'StepCounter::step' from type 'void (StepCounter::)()' to type 'void (*)()... |
I have been using Repositories in my ASP.NET MVC projects and I felt the need to fully cache small tables data (dictionaries, cities, countries etc.). This kind of information is changed (very) infrequently, so caching brings a great benefit. Also, I thought it would be nice to have cached repositories setup as simple... |
I have a myDiv.mousedown, window.mousemove, and window.mouseup event. I'm trying to organize my code, and have it clean. So I created a function and returned the 3 event handlers.
The mousedown event adds a mousemove event, and the mouseup event removes the mousemove event.
Since I need to pass the exact same object to... |
I am a beginner in coding, writing my first bigger C++ project (aircraft initial sizing program). This code should be able to analyze the design in a probabilistic manner by using Monte Carlo Simulation. Hence, I have to generate random values for several independent random variables.
As I want to learn, how to program... |
I've create a function that rewrites the key or "path" of an object in s3.
By default, Amazon Web Services Firehose writes to s3 in the format of YYYY/MM/DD/HH/foo.json. We have a AWS Lambda function listening for putObjects on l1/source/event_type/fh/, and when a new file is added to s3, the Lambda is invoked and the... |
Background
Disclaimer: Skip if you are not interested in the background. The code is far far simpler than this.
The problem is more about programming than math. Here is the definition of multiplication with broadcasting in human readable language.
I am trying to optimize the multiplication of large n-dimensional a... |
Another journey down the difficult path! I'd like to know if there's anything I haven't accounted for, if this can be significantly improved, etc.
(Just as a side-note, I know that some of the formatting is a bit off; some places are spaced out a bit to make it more visually appealing.)
using System;
namespace Data
{
... |
This problem is taken from the book Introduction to Algorithms, Third Edition By Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest and Clifford Stein:
In order to transform one source string of text x[1..m] to a target
string y[1..n], we can perform various transformation operations.
Our goal is, given x an... |
I recently wrote a simple Brainfuck interpreter in Ruby:
require "io/console"
$VALID = "+-<>.,"
def parse(code, level=0)
ast = []
while !code.empty? do
c = code.shift
if c == "]" then
if level == 0 then
throw Exception.new "Unmatched brackets"
else
... |
I made a simple insertion sort in F#, it uses a tail recursive shift function that attempts to shift an element in a list until it is in the right order. Would like some feedback on the design.
let insertionSort xs =
let shiftInsert xs x =
let rec shift xs x f =
match xs with
| [] ->... |
In my previous post I was looking for a better solution to write a single column of a 2D array into a worksheet besides looping between code and worksheet and finally managed to achieve that.
On deploying my code, I found that the double loop to compare two arrays was inefficient when it came to comparing arrays of 5,0... |
I'm testing my game using Firefox, and it's slow whenever it's in fullscreen. If I resize the browser to take up half the screen, it'll scale the image down and run fine. Game also runs fine in Chrome in full screen. I'm using a laptop with an i7 4000HD series CPU..
The window size shouldn't make a difference, as I hav... |
Looking for a general review:
#ifndef HASH_TABLE_HASH_TABLE_H
#define HASH_TABLE_HASH_TABLE_H
#include <utility>
#include <stdexcept>
namespace mds {
template<typename K, typename V >
class hash_table {
std::size_t M;
std::pair<K, V> *table;
bool *mark;
std::siz... |
How can I improve this code? It computes the Ackermann function as long as m<4 and n<13.
#include <iostream>
#include <limits>
// Ackermann function calculations
unsigned int ackermann(unsigned int m, unsigned int n){
if(m == 0)
return n+1;
if(n == 0)
return ackermann(m-1,1);
return ackerma... |
I have two implementation which I modified according to my need to create a triangle or a pyramid like this:
*
***
*****
*******
*********
First way:
int num = 5;
for(int i=0;i<num;i++) {
for(int j=0;j<num-i;j++) {
System.out.print(" ");
}
for(int k=0;k<=i;k++) {
System.out... |
This is a follow up to my last question:
Partition a singly linked list using Java
Based on the feedback I received there, I changed the following about the code:
Added a LinkedList class.
Removed some variables from the partition method.
Changed the partition algorithm so that the output of the lower and upper partit... |
A few days ago I asked this question. So far I have made many changes in the code, as well as added some on and I was wondering if you see any way the code could be obviously optimized, as well as any suggestions you may have.
Note: I was thinking for the vampire race I would create a const variable called vampireFood... |
The parameters list contain the array that is passed to and the size of the array respectively. Is there anywhere I could improve my code?
void bubbleSort(int a[], int s) {
for (int i = 1; i < s; i++) {
for (int j = 0; j < s - i; j++) {
if (a[j] > a[j + 1]) {
int temp = a[j];
... |
I am trying to implement search in Laravel. I want to search on models. Since there can be many records in the database, I am trying the chunk function.
public function searchLeads($param)
{
$results = array();
// get all leads
Lead::chunk(100, function($leads) use ($results, $param) {
... |
The parameters list contain the array that is passed to and the size of the array respectively. Is there anywhere I could improve my code?
void insertionSort(int a[], int s) {
for (int i = 0; i < s - 1; i++) {
int j = i + 1;
int key = a[j];
while (i >= 0 && a[i] > key) {
a[i+1] =... |
This is the complete rewrite of a function to decode an UTF-8 codepoints and return the encoding length (or 0 if the codepoint is \0). In response to the review of my previous version I decided that I needed a different approach and I should recognize ALL the invalid encodings (as per reviewer suggestion). If an invali... |
In one site there was one practice question which ask you to make one program:
Tapas and Meghana are appointed as the one responsible for interviews
of AXIS Core committee '17 ! In order to decide upon the order in
which to call the aspirants for the interview, they have come up with
a brilliant game. It goes li... |
Is there anything to make the cosine similarity function more optimized in terms of CPU execution time?
double cosine_similarity(double *A, double *B, unsigned int size)
{
double mul = 0.0, d_a = 0.0, d_b = 0.0 ;
for(unsigned int i = 0; i < size; ++i)
{
mul += A[i] * B[i] ;
d_a += A[i] * A... |
First of all I know my code is highly vulnerable to SQL injections, but I wanted to code the base first. I have a feeling this can be done with fewer lines and less repeating. I'm sorry if it is really bad code I just started learning C#.
public DataTable GetData(string search, int filter)
{
switch ... |
Accomplishment: Tic Tac Toe game with Python & Kivy
I have created a simple tic tac toe game with a random bot logic (really random after a user selects a mark). Next step would be to insert the minimax algorithm for example, but I would like to know if the path I've taken to construct my code is correct and could it b... |
This is a simple library I just finished writing. The main function is entropy(), which returns the entropy of a file. I'd really appreciate suggestions to improve it.
caos.c:
#include <stdio.h>
#include <math.h>
#include <unistd.h>
#include <sys/stat.h>
#include "caos.h"
static unsigned long long int wc(const char * ... |
I'm trying to make a random object spawning script in Unity.
Bellow is the code, any suggestions for improvement / changes?
I'm new to both Unity and C#.
// Game objects and Transforms
public Transform playerTransform;
public Transform[] obstaclePrefab;
// spawn params
public float minYDicstane = 6.0f;
public float ma... |
It occurred to me that if SHA2 can be used to derive keys from passwords, then it might as well be good enough to generate random data that can be xored with a plaintext to encrypt and the other way around.
These are my assumptions:
SHA-512 produces a random-looking output that is impossible to guess
The result of SHA... |
So I was thinking of making a C# REPL, as I didn't find any viable solution that would work for me, so I made a simple, basic one, I am sure it can be improved, as it seems once the REPL class is initialized it's hard to add an event handler to it, or access the logs, so I am looking for a way to improve it, here's the... |
I'm learning Clojure and solved Project Euler #1, I'd like to have my code reviewed on all aspects and have one specific question. This is also my first Functional Programming language, I have however used some form of FP in Java and Python before.
Task: Multiples of 3 and 5
If we list all the natural numbers below 10... |
I am getting some customer data but don't know the complete schema beforehand. I want to parse this data and create a Scala object from it. But due to unknown fields in the record, I fill only the important fields and remaining record data is dumped in a remData placeholder field. This remData is used so that we can st... |
I am studying computer science and recently I developed an application in Java (it is a minecraft mod) that connects a MySQL database and queries to fetch, update or insert data. My DatabaseHandler class is the one that initialize the connection to the database and performs all the necessary queries my application need... |
Today I spent quite some time on providing a solution for a Stack Overflow answer. It looked quite easy to me, but my solution is complex.
The question can be found here and this is my answer.
If I understood the question correctly it came down to obtaining all values for keyWeWants from a data structure like this:
{
... |
I have written some code (below) which iterates over each character of a string and adds that character to every index of previous permutations.
For example, in case of abc: b is added to every index of perm(a) resulting in ab, ba.
Now c is added to every index of perm(c) resulting in cab, abc, acb, cba, bac, bca.
I us... |
I have an example array like:
array = [1, 2, 3, 4, 5, 6]
Every of this numbers refers to an object that has text property. I want to make sure that every of these object has the same text value.
Currently I do it like this:
correct = []
for number in array:
if(object[number].text == "Sample"):
correct.append(num... |
I'm learning Clojure and solved Project Euler #1, I'd like to have my code reviewed on all aspects. I'm marking this as follow-up of Project Euler #1 because I answered my own question and implemented it.
Task: Multiples of 3 and 5
If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, ... |
Below is the current working code for an ongoing project.
I am wondering if there is anything I can do to improve the code snippet below. My main concerns lie to two area. First being that I append the answer of an input to a list called inputList and then call it in a block of conditionals. I am wondering if this in p... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.