instruction stringlengths 71 71.9k |
|---|
I have made a mental Maths game but it seems quite long, is there anyway in which I can simplify it? And can you also help me with my other Maths game, Ten quick questions ?
correctq=0
actualanswer = 0
print("Welcome to Mental Maths")
print("If you chose Division rpund down to the nearest whole number")
mode = input("(... |
Like my previous question about my Mental Maths game , I have written a script for a ten questions Maths game and again it seems like there is a more simple method, can anyone take me out of the dark on this one?
def tenquestions():
mode=input("(E)asy, (M)edium, (H)ard")
questions=0
rightqs=0
while ques... |
This code takes the position of your mouse cursor, and it creates circles where the cursor is.
strokeWeight(3);
stroke(24, 0, 0);
fill(245, 0, 0);
background(255, 255, 255);
draw = function() {
ellipse(mouseX, mouseY, 30, 30)
};
I would like to know:
If there is a way to shorten this code, but sti... |
I'm trying to check in my meteor app for a defined timeout (idle user) to show a modal. But the way I did it seems a bit too complicated to me.
I'm doing a setInterval for 1 minute. Then a counter - which is stored in a Session var (maybe a local reactive var would be smarter?) - will be incremented by one. If there is... |
I have this monstrosity
@nation_biopsy =
User.all.where(country: @nation).group_by{ |u| [u.institute_type, u.biopsy] }
.map{ |i, o| ["name" => i[0], "y" => User.where(id: o.map(&:id))
.sum("biopsy")]}.flatten.to_json
What it is doing is finding all the users in my database that belong to a cou... |
I have two datasets that are both within a worksheet, call them Data and IBES. The code checks whether the 6 variables are the same in each dataset and then writes the value from a specific column to the other dataset. To find this value the code runs through 288503 lines which is dramatically slow.
How can I speed up ... |
I have 3 different functions I have tried in my programs. I want a function which continues to loop until an integer is entered. Which would be the best to use? Or is there a better one?
def valid_int(question):
"""Creates a loop until an integer is entered"""
py_version = find_version()
if py_version == 3... |
See this post for the previous question. I have made several enhancements to this compiler and language that make it a lot easier to work with, as well as slightly decreasing executable size (if new features are used properly). I've decided to call the new language brainfix, as I don't think anyone has used this name b... |
Here is my latest version of my addition script. I have tried to take on all the advice I have been given by people like @Janos and @Hosch250 and also tried to keep to the guidelines set by the PEP8 (I recommend it to anyone who hasn't read it yet). Now I have done it, so please tell me if I have missed anything/there... |
I made an Atari breakout game from Java from an inspiration from Google's Atari Breakout Doodle.
Here is the code for the main Controller:
This actually works. Try it by putting it all in an atariBreakout folder.
package atariBreakout;
import java.awt.*;
import java.awt.event.*;
import java.util.ArrayList;
import java... |
I have created some code to split strings. The code will split the given string by the given delimiter into an array which is inside a struct it returns.
I am using strtok to do the actual tokenizing, but in my code the original string will not be changed.
split.h
#ifndef SPLIT_H
#define SPLIT_H
#ifdef __cplusplus
ex... |
In my application, well-defined operations on collections of business entities are modularized and carried out using one or more routines, each of which operates on a unique type of data associated with (but not necessarily contained in the objects that represent) these business entities.
A routine may have logic that... |
I am implementing the said question on "Cracking the Coding interview" using HashSet. Please have a look and suggest how I can improve the efficiency of the following code considering that I am only taking either all lower case or upper case characters.
static void detrUniqChar(String str)
{
int flag = 0; //Flag decla... |
I have made a game (I like to code when in my spare time) where words are taken at random from a list and displayed on a label. If they type it correctly, their wordcount goes up by 1 and the word is removed from the list. If they get it wrong, the word remains. If they enter nothing in an attempt to skip the long word... |
1. Problem Statement
Write a JavaScript function calcCircleArea(r) that takes as a parameter the radius of a circle and calculates and returns its area. Put the function in a file named circle-area.js. Write a HTML page circle-area.html that includes the script circle-area.js and calculates and prints in the page body... |
I decided to try to make my own tree style class.
I may use it in a project, but it's primarily to practice.
I would appreciate any feedback for improvements, best practices, etc.
import sys
class Node(object):
def __init__(self, name=None, data=None, parent=None):
self.name = name
self.data = data... |
Reads the user's first and last name (an entire line as a single string), then prints the last name followed by a comma and the first initial. Ensure the code re-prompts until the user types a name that is at least 5 letters total in length and has at least one space in it. For example:
Type your name: Jessica Miller... |
This is my EventHandler class, which is extremely simple and can be used on lambdas and similar:
template<typename Signature, typename...Ax>
class Event
{
private:
typedef std::function<Signature(Ax...)> Function;
Function _func;
public:
void CallFunc(Ax... ax)
{
if (_func)
{
... |
I created a simple Authorization module with Rails. I found that there are other authorization systems, such as CanCanCan, but they grant permissions at Model level and, for this particular website I am developing, it is more convenient to authorize at Controller level.
The idea is simple: the permissions are stored in... |
I'm working on making an iOS app to solve physics problems and I'm starting by just having it solve basic kinematics problems with the following formulas (I've coded it in C instead of Swift to start because I know C better):
Time: \$t\$
Change in Distance: \$d\$
Average Velocity: \$v_a\$
Initial Velocity: \$v_i\$
Fi... |
I have the following algorithm to find a minimum of three input numbers:
min(a,b,c):
x := a
if b < x then x := b
if c < x then x := c
return x
end min(a,b,c)
I'm trying to implement a Mic-1 micro code following the algorithms above:
OP1, OP2, OP3 = any 16 bit 2s complement value
OPRES: 0
.LOC 50
main... |
This year I have been participating in the Advent of Code series of challenges, and it just so happened that I'd be doing them in Javascript. Not my usual weapon of choice, but I do have some experience in it.
Day 11 asks us to find the next valid password given a set of three requirements. The idea is that you'd be in... |
I just finished coding a game of 21, similar to Blackjack, but with a simplified dealing mechanism.
#include <iostream>
using namespace std;
#include <string>
#include <ctime>
#include <cstdlib>
int main()
{
bool loop = true;
int loopchoice;
srand(time(0));
int player1 = 1+(rand()%10);
int player2 ... |
(See the previous iteration.)
Now I have optimized my natural merge sort: Suppose the input sequence is
$$\langle 2, 1, 4, 3, 6, 5, \dots, n, n - 1 \rangle.$$
My previous iterations would degrade to \$\Theta(n \log n)\$ on this input. This version will not: After reversing the second run (\$\langle 4, 3 \rangle\$), the... |
Currently I'm engaged with implementing a Drag and Drop GUI.
I've discovered that there a not many resources (tutorials, etc.) available. So I wrote this:
function Cursor(cssSelector, rightLimit, bottomLimit) {
var element = document.querySelector('#square');
var styles = window.getComputedStyle(square);
... |
I want to customise how my objects are printed using the .format() function.
I have two problems to make that happen in clear and concise way. But since the second one stems from the first one I'm presenting both here.
Formatting array
Passing options to .format() in array seems to me to be awfully messy if I want to m... |
I need to handle concurrent request by waiting the result of an already running operation.
Requests for data may come in simultaneously with same/different credentials.
For each unique set of credentials there can be at most one GetDataInternal call in progress, with the result from that one call returned to all queued... |
I wrote a quick program in Python to play against itself in a game of (random) tic-tac-toe.
It seems to work, but can you guys please look at it and let me know if I'm doing things the 'correct' (i.e. idiomatic) and efficient way.
import random
# Tic Tac Toe
# Board is laid out as:
# 0, 1, 2,
# 3, 4, 5,
# 6, 7, ... |
I know this code works, but is it correct to define them as functions or should I use something else?
import math
def Fibonnacci_sequence():
i=int(input("How many numbers of the fibonnacci sequence do you want to see: "))
a = 1
b = 1
n = 1
print(a)
print(b)
n = n + 1
while n < i:
... |
Your method should accept a real number as a parameter representing a limit, and should add and print terms of the sequence until the sum of terms meets or exceeds that limit. For example, if your method is passed 2.0, print terms until the sum of those terms is at >= 2.0. You should round your answer to 3 digits past... |
I have a filter method that receives a list composed of dictionaries. You must discard dictionaries that have their handle or their citizen_number elements off the filtered result as well as concatenate any lists inside that dictionary. In addition to that, in case an element on that main list is a Noneit should be ski... |
I would love a code review of this LSD radix sort implementation. I've rolled my own, and have implemented counting sort as well. I feel like some of the data structures I've chosen could be improved. My List<List<char[]>>, for instance, is a little gross and makes fiddling with its innards more complex than I think ne... |
For my CS class, I need to, by the end, have written an entire website. The idea for my site is to supply information about Uromastyces. Because of this, most of each page will be nearly identical. The only part that changes will be the main body that contains unique information (this seems to be common on most large s... |
I've been trying to figure out how to stop Twig escape using the following code, which I feel is a little nicer with the succinct ternary operator.
I hope someone can confirm I'm using the correct syntax and if there are any performance issues doing it like this (as well as alternative methods, if any):
<body{{ bodyCla... |
Diffie-Hellman is a key exchange that allows 2 people to share a symmetric key without interaction beforehand. First, a person shares an equation; in this case, we use:
$$3^x \mod{17}$$
Next, each person generates a random, usually prime, number. Then, they plug it in the equation. Let's use 5 and 7:
Alice: \$3^5 \mod... |
A interesting challenge was brought to my attention: to "flip" an array. I thought it might be more convenient if its bounds were symmetrical, say [-N..N] instead of [0 .. 2N + 1].
Now I'm curious about what could be done to make this Array more mature. Say, like a Boost component.
#include <cassert>
#include <iostream... |
This SQL query took 38 minutes to delete just 10K of rows. How can I optimize it?
Index already exists for CREATEDATE from table2.
declare @tmpcount int
declare @counter int
SET @counter = 0
SET @tmpcount = 1
WHILE @counter <> @tmpcount
BEGIN
SET ROWCOUNT 10000
SET @counter = @counter + 1
DELETE table1
... |
Following the paradigms of SCARY iterators, there should only be a single iterator-type for contiguous iterators per value-type.
Here my code for that iterator, working with C++11+:
#include <type_traits>
#include <iterator>
template<class T, class U>
struct is_more_cv_qualified : std::integral_constant<bool, std::is_... |
Given a string of digits, find the minimum number of additions
required for the string to equal some target number. Each addition is
the equivalent of inserting a plus sign somewhere into the string of
digits. After all plus signs are inserted, evaluate the sum as usual.
For example, consider the string "12" (... |
I have developed small test project as a template for production project.
In this template I've found a way that the application saves and loads its own settings (ini-file).
Main Form1 will contain many other sub-forms Form2, Form3, ... FormN
Each sub-form has its own settings, but only main form is responsible for s... |
Every call to the web service goes through a custom queuing system. This has a limit that is set to 1. Every call that enters the same time with another call is purged and not handled. Not sure if this is completely thread safe.
public void QueueForExecution(T value)
{
lock (_queueLock)
{
if (_entryCoun... |
I'm a beginner at coding, and I am looking to improve the structure of how I write code and will take any tips. Posted a simple program that takes your name as input, then runs the string through a switch statement to print out how many of each character your name has, as well as any spaces and symbols.
package practic... |
var fpslist = db.FPSinformations.Where(x => x.Godown_Code != null && x.Godown_Code == godownid).ToList();
var data1 = fpslist.GroupBy(x => x.Ration_Card_Type1)
.Select(x => new
{
CardType_Name = x.Key,
CardType_Count = x.Sum(y => y.Ration_Card_Count1)
}).ToList();
var data2 = fpslist.GroupBy... |
So I have a simple userform where I require the User to input the target month, and the day to analyse data up to.
This is just a small section of code to govern populating the month selection and then determining days based on the month.
Particular questions:
Is this a smart way to handle dates generally?
Is this a go... |
I've written the code below with what little knowledge I have of JavaScript at the moment.
The code simulates the process of removing multiple videos at once from a playlist like the one you see on YouTube. As it stands now, the code removes a total of four videos (each positioned at the index 0, 2, 5, and 7), using th... |
I thought Ver 2 was fairly solid but ending up modifying all but one method for Ver 3. Performance for Generate is the same, but I was able to simplify the method even further. SaveImage is now 12X faster. New to this version is the ability to specify how many ranges to be used when using TPL Parallel.For.
using Sys... |
My current implementation,
class Person {
int id;
String name;
LocalDate start;
LocalDate end;
/*getters and setters*/
...
}
private void checkForTimespanOverlaps(List<Person> persons)
{
final int totalPersons = superiorSalesAgentHasFunctionDTOs.size();
LocalDate[][] timespans = n... |
CreateUser function assumes the data being delivered via parameters are clean and gets called or initiated from the Business Manager (another class). This function is responsible to do the following things:
Fetch the Connection String
Open the database connection
Start the transaction
Inserts a user record
Loop throug... |
Here is the completed code for my first Python project, for which I received some help and feedback here: Collate votes on MP3 files to list them by popularity
Seeing as there have been considerable changes since that post, I figured it would be best to start a new post.
My goals when starting this project were:
Scan ... |
I've made an image filtering client for JavaScript that runs on jQuery, Vex and Fabric.JS.
You simply include the required files in your html page, along with something like:
<script type="text/javascript">
ImageFilter.defaultOptions.imageCallback = server.upload();
</script>
and then have a <a><img /></a> structu... |
I was playing a game with my family and we lost the dice that went with the game, so I created this small program and I am now trying to create a website with it.
mouseClicked = function()
{
// change to change max and minimum numbers
var number= random(0.5, 6.4);
// makes number into intiger
var integer = roun... |
I want to make sure if it's good. Maybe there is another better solution.
List<String[]> list = new ArrayList<String[]>();
for (int i = 0; i < 3; i++) {
String[] arr = { String.valueOf(i) };
list.add(arr);
}
String json = new Gson().toJson(list);
System.out.println(json);
Expected outp... |
How can I improve this code?
var maxDateValue = list.Where(x => x.ID == 1).Max(c => c.LastUpdDt);
list.RemoveAll(x => x.ID == 1 & x.LastUpdDt!= maxDateValue);
|
This is a statement that I use a lot in my code base:
(LocalDateTime.now()).format(DateTimeFormatter.ofPattern("ssmmHHddMMMuu"))
Should I create a static method for this or is it overkill?
public static String getTodaysDateInFormat(String format){
return (LocalDateTime.now()).format(DateTimeFormatter.ofPattern(form... |
I have a library of news articles. Each story is unique by id.
public String getStory(String id) throws Exception {
Connection conn = MysqlDb.getConn(dbName);
try {
for(Publisher p : Publishers) {
PreparedStatement prpStmt = conn.prepareStatement("SELECT story FROM " + p + ... |
Inspired by a few inverse tree ascii art F# questions, I wanted to give it a shot in Haskell.
As seen in the linked questions, the resulting program reads an Int from stdin (\$0 \leq n \leq 5\$), and displays a tree of dimensions 100 * 63, consisting of \$n\$ Y-formed "trunks-and-branches" of which the three arms each ... |
I am working with an array-like data container through a 3rd party API. So I can not change the container itself to add iterators. There are many different array-like classes, and each have a specific data type it will store. There are two unknowns in this case, the class of the array container and the data type stored... |
I decided to rewrite a previous program of mine from scratch. The result is a lot better than the previous one but now that it seems like it is working I want to optimize it (hopefully it is not too early..).
Provided a UrlList.txt, it read line by line the urls of a manga page, e.g. http://www.readmanga.today/naruto a... |
I believe this runs in \$O(V+E)\$ but I wouldn't be able to explain the reasons why. I was looking for some general code review and any help on understanding the runtime.
var Graph = function() {
this.adj = {};
}
Graph.prototype.addEdge = function(v, w) {
if (!Array.isArray(this.adj[v])) this.adj[v] = [];
... |
I built an app that allows users to add and remove images in a collection view. I want this to be useful online so I save the images into a database and retrieve them every time. I'm looking for constructive criticism on how I solved this problem. It is in swift. The code works just fine, but I notice some lag sometime... |
I am creating a website for my buddies and I to track all of our offensive softball stats. I am getting tired of maintaining a huge excel spreadsheet and emailing it out every week, so a website is the way to go.
I've created the DB a few times but I want to make sure I am making this thing right without duplicating da... |
I am designing a cipher and need to convert between bases repeatedly in a loop. I have optimized everything else, but I'm not too familiar with C++ code, and and am trying to figure out how to make the conversion faster.
string digits = "0123456789abcdef";
string tohex(string number) { // Decima... |
I use this script to scrape the results of a SEDE page and return as a BeautifulSoup object.
A small twist is that if I don't use a SEDE query manually in the browser for a few days, then non-interactive downloads get empty results. (I suspect there is a robot test there.)
Rather than fixing the robot test issue, my wo... |
This is a concept for a compositor. It would help me if you could review how well I expressed my ideas into the functional language.
I first divide everything in an areas that each window covers entirely or not:
Then I can walk the areas and render each corresponding window.
The actual composing of the vectors is a ty... |
This is my first attempt at writing a template class. I am implementing Andrew's Monotone Chain algorithm, as described here to calculate a 2D Convex Hull. Since this is my first try at templates, I would like a review of my code to make sure I get started on the right track.
ConvexHull2d.h
// ConvexHull2D
// Template ... |
I saw a post in chat a few days ago, of what I thought was an interesting (albeit fairly simple) statistical challenge:
By @skiwi:
If I shoot once with 50% chance of target A and 50% of target B, and if I hit target A I have 95% chance to shoot again, then how many of target A will I hit on average?
So I broke out th... |
I have just started trying to learn Haskell and tried to think of a practical, but simple problem to try and solve. I have a strong background in C, but am just beginning to dip my toes in the world of functional programming.
The idea came from my investing in notes on Prosper: given a list of note ratings, and a des... |
I just recently started working on python (interesting language, actually), and, as I always do when I learn a new language (with the exception of BrainFuck, that's too hard), I write a FizzBuzz program.
I notice there is no error-checking, so my program would have problems with incorrect input, but please ignore that ... |
I wrote a Java class to make a GIF animation from a list of images. The whole project can be found here.
I am pretty new with GitHub, so I would be very glad if you can give critiques regarding my project structure.
package shine.htetaung.giffer;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io... |
Is this a proper way to cache side effects (occurring on job.tryLoad)?
case class DFStorage(private var cache: Map[String, DataFrame] = Map()) {
def tryLoad(job: Job): Kleisli[IO, MakeContext, \/[List[String], Unit]] = {
if(!cache.contains(job.id)) {
job.tryLoad.map(_.map(df => add(job, df)))
} else {
... |
I'm building an app that serves videos to a front end client. My stack is Express/Angular/SQLite. The db doesn't hold users, only root. I'm concerned that my controllers are too hardcoded, but I'm wary of the balance between making controllers too dynamic such that I'm merely pigeonholing myself into an over-engineered... |
I've just finished up a functional emailing client in the Java language. It applies the JavaFX libraries and the JavaMail/activation APIs.
Give the source a read through and make all the suggestions you think of, please. I'm in the process now of cleaning it up since it was just finished, but address any discrepancies ... |
The idea is to batch download a list of movies (torrents) off a torrent site and add them to your server.
I have a little bit of Java experience (sophomore in college), so I'm looking for things that I could improve on.
Main.java
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.u... |
The octoberCMS(based on laravel) controller below is what I use to select the lowest price in 4 pricelists in the given daterange.
Prices can vary and it's not guaranteed that the more expensive sounding categories will have higher prices.
I have 4 relations in my model pricelist_bronze, pricelist_silver, pricelist_gol... |
I'm trying to read in a few lines of parameters from an textfile and format these paths.
How can I improve this code to work with less lists? I just need the final paths.
import os
config = open("C:\\Users\\config.txt")
content = config.readlines()
removedEnds = []
removedStarts = []
finalPaths = []
for string in cont... |
I have a simple class that I use to logging errors and other informations from my applications.
I wondering what will happen when 2 or more threads of the same application would like to log something to file. What will happen when they call Log() function at the same time?
The more important question is how could I mak... |
I have a lot of Task continuation that depend on .Result of previous Task -> for example: I have a command that should:
Stop previous instance
Copy files elsewhere
Delete original files
Start instance again
So for example the command function:
public Task<CommandResult> Execute(ICommandArguments arguments)
{
Task... |
I'm brand new to Python and I feel my code is really like what coded in Java.
I try to practice python by small problem and that is to find the maximum population of R-pentomino. Wiki says:
During this early research, Conway discovered that the R-pentomino
failed to stabilize in a small number of generations. In fa... |
I need to write a software in JAVA which allows me to simulate the transfer of some images over a noisy channel while adding redundancy with a repetition code
.
Before going into code details and issues, here are some requirements:
read files from a directory containing images
for each file, apply a repetition code (w... |
This was one of the tougher challenges on hackerrank.com because the solution had to run under 4s time limit. I had to do a lot of optimization for this one. I had to switch from using Java 8 to Java 7 which for some reason ran much faster and didn't time out on some of the cases.
Any comments on the solution and c... |
I'm using the CakePHP 3.0 to paginate some content, but I can't find a way to change the limit (user on browser choose the limit of content displayed on screen) using Paginator built-in method (like sort built-in), to do this I use javascript to change limit in URL.
Qustion: Exist any way to do this in cakephp style ?
... |
I'm very new to Clojure/ClojureScript and have a question regarding a "proper" way to express something.
This code sends a mail using nodemailer on nodejs:
(defn send-mail [some-id]
(try
(let [clj-props (:mail (config/config-file)) ; get the mail server cofiguration
mail-address (mail-adress-from-props... |
My latest refactoring for Rubberduck is called Introduce Field - it promotes a local variable to a private field.
The three overridden Refactor() methods are the members of IRefactoring, and are used to start the refactoring sequence. The other methods are the worker methods.
Overall, I am pretty happy with it, but th... |
Some fraction of a follow-up to The half-finished version.
What's changed: Added year as well as Day/Month. Added input Validation. Implemented a poor man's .EnableEvents = false for UserForms. Re-jigged the event heirarchy (Change year --> Repopulate Months or Days, Change Months --> Repopulate Days).
As always, all ... |
I am still new to VBA. I recorded several actions that I need to perform to ensure that a specific worksheet is formatted properly.
Row 1 contains headers. Other than the headers, there is no data in the sheet when this should be run. I know that the raw code from the recording can be shrunk down, but I would appreciat... |
I have a query to split a delimited string into to multiple columns. The query is extremely slow and takes more than 5 minutes to handle 80444 rows. How can I improve execution time?
WITH cte (Execution_ID,Intake_Generic_ID, [File_Name],F1,Report_Attributes) AS ( SELECT
Execution_ID, Intake_Generic_ID,
[Fil... |
Problem Statement
Find the max sequence finder.
findMaxSequence([3, 2, 3, 4, 2, 2, 4]);
findMaxSequence([3, 5, 4, 6, 1, 2, 3, 6, 10, 32]);
findMaxSequence([3, 2, 1]);
Expected Output
[ 2 , 3 , 4 ]
[1, 2, 3, 6, 10, 32]
no
Solution
function findMaxSequence(array, start = -1, end = -1, i = 0, results=[]){
... |
In modern C++, many classes accept a policy type as a template parameter. The author of the class does not know in advance what kind of policy its class will be instantiated with. If the policy class is empty, it would be desirable to inherit from it so to leverage the empty base optimization (EBO). On the other hand, ... |
Based on this question, I have made a simple program to print a sequence of random numbers. The program seems to run fine, but I would like to know if my implementation is correct and how I can improve it.
#include <random>
#include <array>
#include <algorithm>
#include <functional>
#include <iostream>
template<class ... |
You are writing your web-page and relentlessly adding links, as you think that links are the best thing a web-page can offer.
The fact is that you write links even to pages that do not exist just yet, because you will write them later.
But later becomes a lot later and now you have your website in your directory with a... |
This is my solution to Project Euler 14:
The following iterative sequence is defined for the set of positive integers:
n → n/2 (n is even)
n → 3n + 1 (n is odd)
Using the rule above and starting with 13, we generate the following sequence:
13 → 40 → 20 → 10 → 5 → 16 → 8 → 4 → 2 → 1
It can be seen that this sequence ... |
Write a method named numUnique that accepts a sorted array of integers as a parameter and that returns the number of unique values in the array. The array is guaranteed to be in sorted order, which means that duplicates will be grouped together.
I'm mainly concerned with following proper conventions and maximizing r... |
Recently I found the need to implement a normalization formula in a couple of places in my basketball game, so I created some static methods inside of a class to do so.
public class Normalize {
//explanation of normalization formula:
/*
Suppose you have a range or scale from A to B and you want to convert ... |
I am working on a library which will make HTTP call to my rest service basis on inputs passed to this library. And whatever response comes back from service whether it is successful response or failure coming from the service or something happened in this library like timeout or any other errors, I am returning a respo... |
Below is the assignment I was given and the coding is what I have came up with. I would appreciate criticism on how I did and on ways to have gone differently about it.
You want to number your random list numbers, so use an iterator to put the list numbers into a map (but keep the list). The key will be the number th... |
I wrote a random file opener in Python that takes file extensions as a tuple at code level, and directory/amount at console level:
import os
import random
import sys
class RandomFileOpener():
def __init__(self, positives, file_exts):
self.file_list_complete = []
self.amount_to_open = 0 #So it can... |
I've created a simple static website generator called pjen. The GitHub repository can be found here.
import os
class pjen:
def __init__(self, path=None):
"""
By default, the path will be set to the current working directory,
or the path can be specified using the 'path' keyword parameter.
... |
Problem: Integer partition without re-arrangement
Input: An arrangement S of nonnegative numbers {s1, . . . , sn} and an integer k.
Output: The largest job from partitioning S into k or fewer ranges, to minimize the maximum sum over all the ranges, without reordering any of the numbers. Also the indexes of the partitio... |
I've read about half of a pretty extensive and popular Python book (I'm a complete beginner) and I decided to get my hands dirty with this little exercise to crystallize all the concepts I've taken in.
The program does as explained above in the title, it creates a showdown situation with random community cards and play... |
All classes on GitHub repo
This is the code for downloading files from a FTP-server running Mozilla Fileserver.
FtpItem is the interface for the two classes FtpFile and FtpFolder; FtpFile represents a file on the server and FtpFolder represents a Folder directory on the server.
FtpUser might be better named FtpHandler ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.