instruction stringlengths 71 71.9k |
|---|
I've just coded this for my country's programming Olympiad. I want to know if this method is a good approach in terms of readability and performance. I would also like to know how to improve it.
Note: We can assume all numbers entered are different, positive and smaller or equal to 100.
#include <stdio.h> ... |
I wrote a couple programs in the past that use VB6's Winsock to achieve TCP communications, but still I'm kinda new to socket programming in .NET.
I needed the same functionality of the Winsock to use in .NET with the advantages of multi-threading and asynchronous support (I'm kinda new to that as well). I couldn't fin... |
So I've made custom binary streams which work like this:
/// \brief Reads a variable from the stream.
/// \tparam T Type of the variable.
/// \param[out] var Variable to read.
/// \return Reference to this stream.
/// \throw TODO
/// \note No endianness conversion will be performed if a byte is not 8 bit
/// wide.
temp... |
Initial post: Sequentially displaying a list of game objects
This file creates a dialogue box and sets the chat history box too inactive. It finds which NPC dialogue to display, creates the list and sets which index of the dialogueList should be active.
This. is what the code looks like being ran in-game.
Initially I c... |
I've written a Bubble Sort algorithm in Java and I want a review on these:
Performance improvements.
Code conventions.
Algorithm design improvements.
Cleaner approaches.
I would highly appreciate if you can review based on the points above, and I would prefer if you can add more points on top if it if you find necess... |
I've written a InsertionSort algorithm in Java and I want a review on these:
Performance improvements.
Code conventions.
Algorithm design improvements.
Cleaner approaches.
I would highly appreciate if you can review based on the points above, and I would prefer if you can add more points on top if it if you find nece... |
This here is a templated singly linked list that I have been working on for the past couple of days in C++. I am not a programmer or computer scientist by training; finishing up my undergrad in physics this fall but trying to add more skills to my toolkit, so to speak.
I have been working my way through implementing th... |
I would like to determine is an array of numbers, is always increasing (for all x, x+1 >= x) or always decreasing (for all x, x+1 =< x). If so return true. Another way to state the problem is, return true if the array is sorted or reverse sorted. Here is the code:
public static boolean isAlwaysIncreasingOrDecreasing(in... |
This shell script writes my environment variables. If there is an argument, the shell script will grep for the argument in the environment variables.
PAGER=more
if type less > /dev/null;then PAGER=less; fi
echo $PAGER
if [ -z ${1+x} ]; then printenv|"$PAGER"; else printenv|grep "$1"|"$PAGER"; fi
If the above script is... |
I coded a small user script with PHP. I'm improving the script, learning from my mistakes. I recently learned about object oriented programming and wrote 2 big god classes (user class and message class). That didn't feel right, so read about the MVC model. I wrote a controller class to handle the big god classes while ... |
Two code files below : the actual logic & the test logic.
Core Logic
package stringBuilder;
public class NoksStringBuilder {
//initial capacity
private static final int INITIAL_SIZE = 3;
String[] stringList = new String[INITIAL_SIZE];
//number of strings in the builder currently
int size = 0;
... |
I made a simple math expressions solver that using a "for" loop iterates over all the characters and stores the numbers and signs in std::vector.
It give support for unlimited parentheses and does multiplications and division before other calculations.
I really appreciate if you give any suggestions.
Here's the code:
u... |
I am very new to coding and I have created this relatively simple code to do with my basic knowledge of the language. However I have had to do with some unwanted code including shutting it down if password is too long. so could anybody help me with any improvements to this?
import time
passwordx = float(input('create ... |
This is my first hand crafted makefile in quite a while. I thought it might be useful for anyone who wants to review the Knights Tour - Improved Refactored Recursive Breadth First Search.
I believe there is a lot of room for improvement on this makefile.
The C++ source code as well as the makefile can be found on git... |
This prints the character that occurs the most in a given string.
Input: String of word(s)
Output: Max occurring character
public class mostOccurringCharacter {
public static Character findMaxOChar(String text){
HashMap<Character, Integer> map = new HashMap<Character, Integer>();
Character maxChar = ' ';
l... |
The program makes HTTP requests (checks video stream status) and calls an external program.
{-# LANGUAGE OverloadedStrings #-}
module Main where
import qualified Data.ByteString.Lazy.Char8 as B
import Control.Lens ((&), (.~), (^.))
import Network.HTTP.Client (HttpException(..))
import Network.Wreq
import Data.Text (Tex... |
The input is an unsorted array of integers. The output should be an array of integers sorted based on the modulus of 3 (or any other number).
It begins with all integers conforming to Integer % 3 == 0 then 1 and then 2.
public class sortByMod {
public static void main(String args[]) throws Exception {
int a[] = {1... |
I'm sure there are better ways to code this. I spent a lot of time re-working the code to get it as clean as possible. I would appreciate any input on what I could change to have the program run more efficiently and look cleaner.
outer = False
while outer == False:
room_list = []
room = ["This place stinks, b... |
I need to initialize several parameters of an object but I also wanted to make it immutable. At the same time I don't want the constructor to take all several parameters because some of them are optional and have default values that the user can change during initialization like an IReadOnlyDictionary so I was experime... |
This is my admin class, DB class and how I use OOP.
I am looking for ways to improve my code to make better use of OOP. Please help me if you think I can improve my code in some way.
db.class.php
class database
{
private $conn;
private $db_name = 'profil_penduduk';
private $db_user = 'root';
private ... |
I have only been coding for a short time and I have written these two functions and am looking to optimise them. If anyone could point out things that could be done better it would be much appreciated.
Please Note:
This code has been reviewed/improved using the suggestions below, take a look:
# Python 3.4.1
# Function ... |
I want to learn some C# syntax/paradigms (I'm more used to Java), and have been wanting to get a bit better at math as well, so I solved ProjectEuler3: Largest prime factor with the following small program in LINQPad. It gives the correct answer and completes in 0.05s-0.08s.
For reference, here is the problem statemen... |
The purpose here is to find if there is a conflict in the given set of start and end times of the meeting time slots listed.
Input: Start and end times of meetings
Output: True / False for conflicts
package code.Misc;
import java.util.ArrayList;
public class Calendar {
static int time [] = new int[1440];
public sta... |
Obviously is the XOR-operator is used in low-level programming-languages used a lot for setting a value back to all bits 0.
For example:
11010 ^ 11010 => 00000
Brought my teacher to figuring a out few exercises.
One is:
"Set the bits of a number back to 0 by using just the bitwise AND (&) and the bitwise NOT (~) opera... |
This is my second take on creating a tcp client C++ class. The class declaration is general but the implementation is Windows only at this stage and uses the Microsoft Winsock WSAEventSelect model.
The first attempt is here:
TCP client library using Winsock WSAEventSelect in C++
for some background.
The changes are mos... |
I am performing search in a contact list using linear search with complexity \$O(n)\$. Please suggest me how to improve search strategy in my code.
public class ContactService {
private Set<Contact> contacts;
public ContactService() {
this.contacts = new TreeSet<>();
}
public void addContact... |
Task is basically:
"Write a function which takes two number as the first two parameter. The third parameter is one of the arithmetic operators (+ , - , * , /). Execute the arithmetic operation (number1 operator number2) and return the result of it."
Here's the first idea I've had:
function calculate(num1, num2, oper... |
Question:
Compare and update the inventory stored in a 2D array against a second 2D array of a fresh delivery. Update the current existing inventory item quantities (in arr1). If an item cannot be found, add the new item and quantity into the inventory array. The returned inventory array should be in alphabetical orde... |
For example, given 15 integers
70, 75, 32, 4, 64, 98, 73, 52, 36, 88, 96, 58, 79, 39, 75
How can we obtain is 72?
4 operators can be used for the 15 integers to get the equation to the answer of 72, which are + - * /. Divison is only allowed where there is no remainder.
A few answers will be
4+32+36+39+52-58-64-70+73... |
I have got this interview question which has asked me to write a production level code which flattens the arbitrary nested array of arrays.
Code
/**
* Flattens the array of arrays.
*
* @param {!Array<?>} elements The nested array elements.
* @return {!Array<?>} The flat list of array objects.
*/
function flatten(e... |
I have an array of hashes, each of which has two attributes: "title" and "Zscore". I want to return either the result of find or the last element. This can be done with:
a = array.select{|i| i["title"] == "some title"}
b = a.find{|i| i["Zscore"].to_f >= 5} || a.last
Is there an elegant way to put the conditional insid... |
This code creates a problem for the user to solve (very simple problem) it will then check if the user has got it right and will say so.
import random
import time
def mathsquestion():
attempts=2
bananas1 = random.randrange(1,40)
bananas2 = random.randrange(30,70)
print('lucy has', bananas1,' bananas an... |
I was very intrigued with the manner to solve this problem. The program needs to know if 2 rectangles fit in another one, considering the lines of the 2 rectangles are always parallel to the other one's.
I know I could just put everything in a single if, but is that more readable? I want to know a good approach for thi... |
Crosspost from here, it was suggested that this is better place to pose my question.
I'm implementing a series of classes in a game that all derive from one base class that references the scripting of the object that it pertains. Most of these are objects that are generated by certain spells/abilities, and very freque... |
I have a matrix (500x500) of integers. For each entry, I need to look at its surrounding neighbours (so 8 elements) and determine what the integers are, and run a function on these integers.
Here what my function looks like right now (R code with the RCpp package).
fx2<- cppFunction('NumericMatrix getNeighbours(Numer... |
I really hate copy and pasting my code from one method to another. It signals something in my brain, "This could be done either more efficiently or more readable". This is used in a minesweeper program I am implementing with a JavaFx GUI (that's not very relevant, but it might help to know). Hopefully this is enough co... |
I'm looking for feedback as to how I've structured the async calls, and If anything should be written differently.
endpoints.js
module.exports = {
lotto: 'https://www.norsk-tipping.no/api-lotto/getResultInfo.json?drawID=',
keno: 'https://www.norsk-tipping.no/api-keno/getResultInfo.json?drawID=',
extra: 'https://w... |
I have this page that allows a user to quickly compile \$\LaTeX\$ code into a mathematical display. Whenever the user compiles the code, that page also generates an URL from which it is possible to view the output simply by visiting the URL:
index.html (Note that this Stack Snippet generates non-working URLs because i... |
I made a Guitar Hero III bot for PC. I was able to beat the song "Through the Fire and Flames" on Expert with the bot which can you see here.
If you watched the video, you can see that the bot misses a few notes, which isn't normal for a BOT to do. When you normally see bots playing Guitar Hero, they never miss a singl... |
I created this Mad Libs generator, but I don't know how to get the value of the key "ans" into a format string tuple. I feel like it's not Pythonic and that it's very convoluted and over-complicated.
Check out on REPL.it
# Our Mad Lib
madlib = "On the %s trip to %s, my %s friend and I decided to invent a game. Since th... |
I am writing a large shell program comprised of several source files. I was looking for a basic import system that accomplishes three goals.
Avoid sourcing entire files for access to just a few functions
Prevent files from being sourced multiple times.
Imported functions must be executed in the context of their scrip... |
I have made a MySQL script to query a table with a set of id using an IN clause and after some reading I found out that there are security issues with it like prone to SQL injections and the likes.
Are there other ways to write this code with a more secure way? Although I'm using PDO, is that really enough?
public fun... |
A while ago I asked for a code review of my automatically keyed map and I have recently had the time to get around to writing some unit tests for it using JUnit4.
The test ensures that all of the "primary" functionality works, i.e. the things that could actually go wrong. The reason I don't test every method is that ha... |
I needed to check the values in various Lists and Maps. In my case, the various types of Objects that needed checking were of four types:
String
List<String>
Map<String, String>
Map<String, List<String>>
So, I came up with the following types test methods:
@Test
public void testString() {
Assert.assertEquals("Str... |
Is there a quicker/better way of doing this, mine works great for small vectors but if i get a vector with an arbitrarily large size this would probably take forever to run. Thanks.(P.S. its been a while since I've written any code so please excuse me for any sloppiness).
/*Fill a vector with integers,
sum each pair of... |
In order to practice my programming skills, I am trying to implement a Button class, to use in pygame. I know there are libraries like PGU, I do this to improve in programming.
I spent a bit of time creating a function to find a good font size for the text inside the button, depending on the length of the text and the ... |
I have a repository method which retrieve a list of items, for example:
StaffID: 250026965
Name: Abbasov Islam
FreeTextName: NULL
StaffID: NULL
Name: NULL
FreeTextName: Antonio Puccio
StaffID: 358
Name: Prosinecki Robert
FreeTextName: NULL
I have to sort this list in this manner:
First the items with StaffID > 0 by ... |
I created a PHP script which will be running 24/7 as a TCP socket server and will send data from the DB back to clients. The code is working, and so far, I see no problems.
However, I can only test it with one client. The info I need is, what will happen when there will be 100+ clients? Can any of you see any weaknesse... |
I am working on a e-shop in ASP.NET MVC, and I just made the listing of product the way I figured out this night. Is it correct? Or should I make it differently? How?
So this is my Product controller, used for displaying the products from Db.
using WebShop.Models;
using System;
using System.Collections.Generic;
using S... |
Sometimes when designing a fluent-api it's important to build an object in a specific way/sequence.
I tried to create such a guided builder and came-up with this:
public class Query
{
public static IFrom Build() { return new Builder(); }
public class Builder : IFrom, IWhere, ISelect, ICreate
{
pub... |
I am receiving and Expression (String) as follows:
String expression = "+name;-age;-city";
I parse this expression by splitting it using ";" and interpreting the +/- signs and create a List<OrderRule>. To wrap this I created the following:
public class OrderExpression {
public HashSet<OrderRule> Rules { get; set; ... |
Essentially I have a large directory with many sub-folders and different formats of files. It reads through XML, JAVA, .txt, etc, in search of a selected String inputted by the user. The results come back as snippets, reading a certain amount of characters previous and after the selected string has been found.
It do... |
I have a GET method that handles paging, filtering, and sorting. Development has been fairly rapid and I'm not completely sold on some of the implementation. A few assumptions have to be made for this method: I'm using System.Dynamic.Linq. I want to put as much work as possible on SQL Server. The page will make use of ... |
In my code, I'm trying to manipulate data for an audit between 3 sheets in a workbook.The first block of my code is to paste the data of items I need to find for the audit from the original sheet onto the 3rd sheet by setting each row equal to the data of the original row in the first sheet. The second block is used to... |
I completed the "Nested Lists" challenge on HackerRank, and would love any feedback on my code.
My program is fed text with the number of students in a classroom, the name of a student, and their grade. For example:
4
Shadab
8
Varun
8.9
Sarvesh
9.5
Harsh
10
The code should return the student with the second lowest g... |
I have some info. that looks like this:
Header Debit Credit
aaaa 20 0
bbbb 0 60
cccc 30 0
xxxx 10 0
xxxx 0 40
xxxx 40 0
xxxx 0 10
oooo 500 0
oooo 0 52
oooo 0 500
pppp 10
pppp 0 10
(Note this starts in col. H)
The idea is that I want to go through this rang... |
To teach myself Rust, I implemented a naive binary tree with support for insert, delete and lookup operations as well as in-order iteration.
I'm still a little rusty (no pun intended) when it comes to writing idiomatic code and especially elegant handling of borrows.
use std::cmp::Ordering;
use std::cmp::Ordering::{Les... |
Please review my implementation of a Circular Singly Linked List.
public class NodeS {
public int num;
public NodeS next;
public NodeS(int n){
this.num = n;
}
}
public class SinglyCircularList {
private static NodeS head = null;
private static NodeS tail = null;
private static i... |
I have been trying to solve this simple problem on SPOJ for quite some time now, but I keep on getting TLE (Time limit exceeded) for some reason.
Since the problem is in Portuguese, a brief description of the problem is like this (without the story):
You are given an array of size N, you have to arrange the array in... |
Given a string, compute recursively a new string where all the
lowercase 'x' chars have been moved to the end of the string.
endX("xxre") → "rexx"
endX("xxhixx") → "hixxxx"
endX("xhixhix") → "hihixxx"
Here's the initial idea I've had:
public String endX(String str) {
ArrayList<Character> track = new ArrayList<Ch... |
I've been slowly learning Python so I want to know what the most Python-esque way of doing things are.
The scenario is that I'm connected to a database with a Customer and a SalesRep table in a database called sports2000. I also have a flat file containing a list of customer id's and salesrep names. My end goal is to ... |
I wanted to make some simple functions that would be used in the encryption and decryption using a Vigenere square.
# Define the alphabet used in the cipher once so as to not define in memory for every encrypt/decrypt action
$global:alphabet = "abcdefghijklmnopqrstuvwxyz"
function Encrypt-VigenereCipherCharacter{
... |
I am new to R and programming. I have a set of ratings for 45000 users and 40 odd movies. I need to predict new ratings for each user based on their pearson correlation with other users. I also need to store the set of similar users for each user-movie combination.The code that I have managed to write is this
# Matrix ... |
My goal is to prepare the Excel file (see the download link at the end) I would share with my non-technical colleagues, so that they enter some data into it and then I was able to automatically generate CSV without having to manually change format of dates, leading zeros and in other special cases (this CSV I will late... |
I am in the process of making a game, and during this endeavour, I have come across problems maintaining a good frames per second while drawing my sprites. When I draw my background image, my frames drop from ~65 to ~30. My background image is simply a green tile 2000x2000 wide, constructed from 900 50*50 tiles.
What c... |
I found an interesting question on Stack Overflow. It involves having two main checkboxes and 4 checkboxes for the 2 main checkboxes group.
I'm new to React and wanted to try this with React. I have two groups of checkboxes, one which shows a list of fruits and another which shows a list of vegetables.
The structure lo... |
I created this countdown timer as a tool to count down the remaining time on a test a few months ago. However, I looked at the code today and it looks like it needs some improvement, but I'm not sure what to fix.
Some problems I've already identified:
It makes a call to a macOS-specific command: say.
It uses the bell... |
This is my invoicing program I made for myself to keep track of purchases people made from me. (Yes I know eBay does this for me but I wanted to see what I could make.) Basically it can search the invoice file for a keyword (the invoice number) or lets you enter a new invoice to a file named usb.txt. It is usb.txt beca... |
I have the following code that that writes large images to disk. My application server is running out of memory and I'm wondering if I could somehow optimize the following:
public void writeImgToDisk(byte[] base64AttachmentInBytes, String dmxi){
String destinationAndFileName = "";
String fileNameMinus... |
I did run this code through StyleCop. Goal was to optimize the reading, parsing and inserting of a file on the web and write the rows to a database table using a stored procedure. Contrast this (roughly) to my most previous code review here: C# helper class - mailto Different code but I feel like I'm making progress, f... |
Here's some code that I've written for implementing a Convolutional Neural Network for recognising handwritten digits from the MNIST dataset over the last two days (after a lot of research into figuring out how to convert mathematical equations into code).
""" Convolutional Neural Network """
import numpy as np
impor... |
I want to speed up the following code, which is from an algorithm class.
I get a list of 200000 nodes where every node is a tuple of the length of 24 where every item is either a 1 or 0.
These items represent a graph where the distance between them is the hamming distance(number of bits that two nodes are different). ... |
Recently I had to add 2 different sets of logic for moving my player around the board. One lets the player pick a location and move him there while the other uses a dice. I'm reusing code for both cases and would like to "merge" them into one thing. Any help and suggestions would be greatly appreciated.
void Update()
... |
I am reviewing some C code (see extract below) that uses inline asm. I believe there are 4 spec violations, 1 inefficiency and 1 honking big design flaw in this code. While some of the problems I'm seeing apply to both the x86 and x64 sections in that code, this post is focused on x64.
Before I'll be allowed to check... |
We have a console application which runs to perform an incremental load of our data warehouse staging area, with data from a number of production databases.
The source database don't necessarily have a rowversion/timestamp/etc. column so we are currently using change data tracking in SQL to load changes to the tables. ... |
I just got into Node.JS and am loving it but I am wondering if I am learning it the right way or using it. This is basically a simple server in Flash but I want to see if am doing it right with handling client connections. This makes a new CurrentPlayer after it gets a login packet and sets the ID and username once the... |
My question is about how to achieve a well-performing animation for a set of ImageViews, so that the foreground fades away and the background stays the same.
Currently, I'm writing a clone of "Color Lines" for Android using a GridLayout as a board and ImageViews as game pieces. Every ImageView uses the same (circular) ... |
I have updated my code from the last time it got reviewed. If anyone has some more suggestions on how I can improve this and/or make it faster it would be appreciated!
def is_prime(num):
'''Calculates whether num is a prime number,
if it is return True otherwise return False'''
# SPECIALCASE: These are spe... |
Input:
1000 23 100 26 32
Output:
23 26 32 100 1000
Since 23 has '2' factors and 26 has '4' factors and 32 has '6' factors, and so on.
Should I use a linked list for these types of problems?
Is my code efficient? Or how can it be optimized?
Code:
#include <stdio.h>
#include <stdlib.h>
int facts(int);
int main(... |
I got a function to recalculate the image size based on two settings.
Force ratio, force the requested ratio, default the original ratio will be used.
Keepsmaller, the uploaded image may never become bigger
If keep smaller is not enabled, by default we will focus calculation on the first reached, it's hard to explain... |
I'm somewhat new to JavaScript and AngularJS, and read in Doug Crockford's book that hoisted function declarations can lead to issues. If you have any pointers on how to structure my file, those would be much appreciated.
(function() {
'use strict';
function PlayerProfileStatsCtrl($q, ColumnService, LookupServ... |
Connect Four kinda caught my eye, and I decided to start from the very basics. Here I have bare-bones implementation for playing the game between two human players on the command line:
Board.java
package net.coderodde.game.connect4;
import java.util.Objects;
/**
* This class implements the actual Connect Four board.... |
I am trying to write the sum of selected NumPy array column and write to a file.
The following code snippet is working fine:
for i in range(int(ldata[2])):
s_u.append(dos2[i][1])
s_d.append(dos2[i][2])
p_u.append(np.sum(dos2[i,[3,5,7]]))
p_d.append(np.sum(dos2[i,[4,6,8]]))
d_u.append(np.sum(dos2[i,[... |
I have a library that will be called in multiple places. Here is my implementation:
var vessel1 = new Vessel();
var vessel2 = new Vessel();
vessel2 should use the same instance as vessel1.
The reason I need a singleton pattern here is because of my _initialize() function. It should only ever be called once and with my... |
I am implementing a lexer for an experimental language by the name "Phoenix", the language supports four primary arithmetic expression for integers only (add, subtract, multiply, divide), variable assignment and print statement.
Typical input:
# this is a comment
value = 1 + 7 / 4 * (30)
print('Value = ', value)
lexer... |
This is my first decorator in Python! I found some of it on the internet but have tweaked it to our needs.
Here is the couple concerns of mine:
Multiple python version compatibility
Is grabbing the self or arg[0] the best way to get the instance of the class?
Any other general improvements!
Here is the decorator.
im... |
I am wondering the best way to setup a database class, to remove repeat code by using OOP. This way if I changed how I connect to the database (switch from PDO to sqlsrv driver) I can just change it in 1 file, instead of all the files that use PDO. I've setup a class that I will show below, but I feel like it may be ha... |
I built a small "todo" app with an object oriented JavaScript approach.
I have spent this morning reading on a few ways to approach this, and I've come up with the following:
document.addEventListener("DOMContentLoaded", function () {
var todo = Object.create(null);
todo.newTodo = function (evt) {
evt.preventD... |
Question
How can the following implementation of fractionParse be made
less ugly? (Preserving unreduced numerators and denominators is supposed to be a feature---as shown in the second example---so using readMaybe s :: Maybe (Ratio Int) doesn't really help.)
Things that irked me in the process of writing it, include:
... |
Any ideas how I could improve this? I already know that there is no checking for anything other than a 1, so you can enter a 2 or an a or a b and it will be interpreted as a 0, not interfering with the program's functionality. What I would like to know is if anyone has any suggestions for improving the logic.
def main(... |
I was wondering if you guys know how to reduce the amount of subselects in this SQL Server Query? I think I'm using bad practices in this:
WITH TotalizedRepairOrders AS
(SELECT SalesOrder,Items,DepartmentName, LastCompletedActivity,NextActivity,Plant,ParallelNextActivity FROM OrdersSynthesis)
SELECT Plant,
... |
This code queries the GitHub followers API and stores the graph in a mongodb collection:
import java.util.Date
import akka.actor._
import akka.routing.RoundRobinPool
import com.mongodb.casbah.Imports._
import org.json4s._
import org.json4s.native.JsonMethods._
import scala.concurrent.ExecutionContext.Implicits.global
... |
I submitted this script as part of a interview process. It was rejected and no reasons were given. I'm wondering what parts of my script were unacceptable. The script works, and satisfies the question, but I must be doing things very wrong.
Use Selenium, Watir, Capybara, or similar to automate the following
user wor... |
I wrote my very first Python program to answer a Super User question. I'm wondering how the application can be rewritten to make it as pythonic as possible.
Unit test
import unittest
import os
import shutil
from DeleteDuplicateInFolderA import DeleteDuplicateInFolderA
class DeleteDuplicateInFolderATest(unittest.TestC... |
I wanted to expand the UIFont class in my application so I could use the large/medium/small letters concept.
I created but for some reason it looks weird. I finished it and it does what's is supposed to do but I am not happy with it. Usually when I have that feeling is because I am messing up big or just being a newbie... |
I know the runtime for generating all permutations is supposed to be \$O(n!)\$. I'm not sure if the code I wrote for it runs in \$O(n!)\$ though. I'm having trouble analyzing its runtime.
The for(char c: cArray) part is in \$O(n)\$. What about for (String s: currResults) and for (int i = 0; i < s.length() + 1; i++)?
pu... |
This is my battle system that I wrote in Lua. Bear with me on this one, this is my first real program that does something besides write hello world. If there is anything that I could have done differently, drop an answer down there and I will take your advice for my next program. Huge shoutout to Jakuje for helping me ... |
I have Producer Threads A, B and C producing 3 different types of events Events A, B and C respectively. The Consumer thread can only process only one Event B at a time, where as it can process any number of Events A & C at a point of time.
Event class:
package codility.question;
public class Event {
private Stri... |
This solves Project Euler 4: Largest palindrome product using C# (specifically, using LINQPad). Any and all suggestions for improvements to either the C# code or the math/algorithm are very welcome.
A palindromic number reads the same both ways. The largest palindrome
made from the product of two 2-digit numbers is... |
This is the x86 version of a C file assignment (I have included both). We were to convert the C code to assembly. I am rather new at assembly and would really appreciate suggestions and help for optimization and functionality.
This is a C implementation of Dijkstra's recursive algorithm for computing the greatest commo... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.