instruction stringlengths 71 71.9k |
|---|
I've been working on the Project Euler problems, so I created a GUI and a Solver class for all the code I've been creating. I'd like to share it with you guys and to get general feedback on my coding and how I chose to organize the class.
You can also give feedback on how I solved the Project Euler problems if you'd li... |
I would like a code review on the coding I did for my assignment. The reason I have asked here is because my lecturer has no intention of going through (Don't ask me why, I asked before and he said no..) and I have no idea if I am doing it right or not.. All my other classmates seems to have different answers too, some... |
I am a high school math and science teacher. I am working with my students on the concepts of algorithms, unit conversions, and functions. In class, to work on all these concepts, we just worked out the process of how to calculate how old someone is in seconds. I thought this was a particularly interesting algorithm... |
Experimenting with vera++ to validate some C++ source files.
https://bitbucket.org/verateam/vera/wiki/Home
vera++ is expandable by providing your own rules in Tcl. To interface with the vera++ parser the following interface is provided:
https://bitbucket.org/verateam/vera/wiki/ScriptAPI
Using the above I have written a... |
Experimenting with vera++ to validate some C++ source files.
https://bitbucket.org/verateam/vera/wiki/Home
vera++ is expandable by providing your own rules in tcl. To interface with the vera++ parser the following interface is provided:
https://bitbucket.org/verateam/vera/wiki/ScriptAPI
Using the above I have written a... |
I know there's a more compact way of doing the following code but I haven't been coding PHP in a while and I completely forgot how. I'm pretty sure it's to do with : and ?'s but I'm unsure.
Basically, if $bind has a value add $bind inside of execute() otherwise just don't.
//Execute Binded Query;
if($bind != false) {
... |
I made some changes to the first code here I wrote and I want to know which one is more correct logically (before the changes or after the changes).
It's really hard to manually test these kind of problems.
This is the first code (without the changes):
public boolean put3D(ItemsUnit item, int p,int n) {
//------i... |
I want to improve my code. In this code I don't like my constructor, but without it I keep getting an error while trying to connect NullPointerException.
package soft;
import java.net.InetAddress;
import java.net.UnknownHostException;
import javax.swing.JOptionPane;
import net.wimpi.modbus.ModbusException;
import net.w... |
This is the link list I just created. It works fine for now, but would want to know if I could make it better.
list.hpp
/******************************************************************************************************
* Purpose: Custom Doubly Linked-list.
*
* Author: Sahil Arora
*
* Version : 1.0
*
* Date ... |
if (isset($_POST["save-options"])) {
foreach ($names_of_array as $type => $value) {
update_option('updated_img', $_POST['show_img_url']);
if (isset($_POST["post0"])) {
update_option($names_of_array[0], true);
} else {
update_option($names_of_array[0], false);
... |
This is a follow up question to 3D bin packing in Java
I finished testing my code's result and started cleaning it up.
Could anyone please tell me what I should do or fix to clean up this code more?
I'm required to put a comment for every instruction line I write. English is not my first language, so maybe some of t... |
i am just start to learn C++ and would like to know if there is a better and efficient way to solve this problem or some recommendations.
Problem: Remove all vowels from file and create new one without
vowels.
Here is my solution.
#include <iostream>
#include <fstream>
bool is_vowel(char &ch) {
ch = tolower(ch... |
<?php
$mnquery=$ob->showDataall("select * from menus where parent_id='0' and delet='0'");
foreach($mnquery as $value)
{
$selquery=$ob->showDataall("select * from menu_permission where staff_id='".$_SESSION['user_id']."'");
foreach($selque... |
I have to make a user creation wizard, there are 3 steps to achieve the insertion of a new user, so every step I have have a validation function to enable the next step.
As a first step for the following markup:
<div>
<div class="block block-bordered">
<div class="block-header bg-gray-lighter">
... |
I wrote a Brainfuck interpreter in JavaScript, however it is quite buggy and I can't figure out what I'm doing wrong. It works for programs I've written, but fails on most programs I find on the internet. It seems that the while loop doesn't work correctly when it is supposed to skip over. When debugging, the value of ... |
I've a lot of data whit prices of a product from different firms by week. I've a class named WeekPrice witch contains a list of firms. Here you've my class structure.
Here you've a little part of the data in JSON format:
[
{
"ID": 1,
"NumberOfWeek": 1,
"Year": 2016,
"Date": "01/04/2... |
Exploring the VBA Application.InputBox method I've realized that catching user cancellation is tricky when type is reference, so return value is a range object.
As cancellation's return value is False I can't assign it to an object with Set, so I've created a UDF to return Nothing when user pressed cancel / Esc.
Funct... |
I've created the unitofwork class
below:
public class UnitOfWork : IUnitOfWork
{
private AppDbContext _context { get; set; }
private IDbTransaction _transaction { get; set; }
private ObjectContext _objectContext { get; set; }
private bool _isDisposed;
public UnitOfWork(AppDbContext context)
{... |
I am trying to merge JSON objects which have common values.
This is the original JSON:
{
"setA":[
{
"setId":"setA"
,"prodId":"A"
,"price":"5"
,"delivertCost":"1"
,"name":"Set_Prod01"
}
,{
"setId":"setA"
,"pr... |
This code is for calculating the perfect squares between two given numbers. User can add the interval as well like for how many intervals he want to check the perfect squares. For example if user enter 4, it means there are 4 different intervals and after that he will insert the tow number for interval 1, similarly two... |
I am extending std::list in order to have access to convenience member functions that simplify my everyday developments (e.g. ways to deal with doubloons, delete all the stored pointers, etc.). I removed some of these member functions, but I kept the essential ones.
#ifndef __PJ_LIST_H__
#define __PJ_LIST_H__
#include... |
I need to create a class which acts as a paginated list. My use case is like this:
I am writing a library which makes a service call to fetch a List<obj>. Since the List<> can be large, the service expects me to call with a PAGE_SIZE. The service has also provided me with a TPS of x which I need call it with.
I need to... |
I wrote a little function that does, I think, what the Excel function does:
Given a value and a table (matrix), search for the row that has value closest to but not greater than the given value. Returns the value of a column in the matrix.
Is there something I'm missing here? It works but seems too easy.
def vlookup(... |
I am trying to implement an OAuth2 service. I am not planning to use it anytime soon (like will write unit tests). This is my fun project I do to practice. I have used the python_jwt library to create and validate signatures.
OAuth Request handler
"""
Copyright (C) 2016 Maruf Maniruzzaman
Website: https://github.com... |
I have an instance of a Java class that I need to call some functions on, using the API exposed by another party. For each call, I need to both check for thrown exceptions, and check the value of the returned boolean. If the boolean is false, I need to read the errorMsg object to see what went wrong. In either error ca... |
For the nth time already I come back with yet another alien sorting algorithm. Today I will present Melsort, implemented from the description I found in the paper Encroaching Lists as a Measure of Presortedness by Skiena.
Melsort
Melsort is a two-step algorithm: first it constructs a set of encroaching lists, then it m... |
interface IJuiceable
{
void MakeJuice();
}
interface ISliceable
{
void MakeSlices();
}
class Fruit:IJuiceable,ISliceable
{
public string Name { get; set; }
public void MakeJuice()=>Console.WriteLine($"Juice from {Name}");
public void MakeSlices()=>Console.WriteLine($"Slices of {Name}"); ... |
I use this for reversing a string, but it has O(n) :
reverse(y.begin(),y.end());
How can I reverse a string in O(n/2) ?
|
I'm having trouble optimizing the Project Euler problem number 23 :
A perfect number is a number for which the sum of its proper divisors is exactly equal to the number. For example, the sum of the proper divisors of 28 would be 1 + 2 + 4 + 7 + 14 = 28, which means that 28 is a perfect number.
A number n is called def... |
Is there anything I need to add or is this the best security possible?
<?php
//Get Sessions Prepared;
session_start();
//If logged in, Logout;
if(!empty($_SESSION['username'])) {
//Remove Sessions to Logout the user;
$params = session_get_cookie_params();
setcookie(session_name(), '', time() - 42000,
... |
I'm trying to learn javascript using project euler and I decided to try to force myself to learn about generators in javascript using problem number 2 which asks us to: Find the sum of the even-valued terms in the fibonacci (f(n)) sequence such that f(n) < 4M , beginning with n=1 is 1, n=2 is 2, n=3 is 3 and so on
My ... |
I'm really confused about the interview I did with a firm. They told my code was not expert, but almost intermediate level java.
Requirements
Football Scoring Dashboard
Develop an application that prints out a scoring dashboard as text during a football match. The football scoring dashboard would have output the follow... |
The HexToString function returning maximum of 16kb even for sources greater than 16KB
string HexStringToString(string HexString)
{
string stringValue = "";
for (int i = 2; i < HexString.Length / 2; i++) // Starting from position too just to avoid the 0x Hex Code that messes stuff up
... |
I am creating a color slider, and I'm trying to make the slider's background-color a dynamic gradient. I've successfully did it, but I feel this can be done in a lot less code than what I have.
What I currently have is, I go through every slider (without a loop), and give it the correct gradient. I'm sure there is a co... |
Like those who have come before me, I foolishly have sought to implement a generic, efficient, idiomatic, and most importantly correct method of comparing floating point numbers for equality. Like those who have come before me, I have most likely failed in at least one of those regards. I'd appreciate comments on any ... |
I have a SQL query to find all delivery orders with multiple purchase orders (one-to-many). Is there a better or shorter way to write this?
SELECT * FROM GR_data
WHERE doNo IN
(
SELECT dt.doNo FROM
(
SELECT doNo, po_number FROM GR_data
WHERE DATALENGTH(Mat_No)<=0
GROUP BY doNo, po_numbe... |
This is a question from programming contest. This contest is already over.
Now, all the prime numbers are arranged sequentially in ascending order. i.e:- 2, 3, 5,7...and so on. Now, your task is to calculate those prime numbers which are present at a prime position. For example, 2 is present at position 1 which is not ... |
I am working on an instant chat messaging application. I am getting contacts from phone and displayed them in list view of an activity, but it is taking 25-30 seconds using the following code:
1. On clicking Contact button:
contacts.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(V... |
This code takes a JSONObject, passes it to another class which is responsible for mapping the data in the JSONObject to a different format (Still a JSONObject though).
I'd just like confirmation if the code below is bad practice or not, I feel it is:
public class DeliveredCommunication{
private String deviceId;
... |
##open file and create a dictionary of {"word":"sorted word"}
word_file = open("word_list(1).txt","r")
word_list = {}
for text in word_file:
simple_text = ''.join(sorted(text.lower().strip()))
word_list.update({text.lower().strip():simple_text})
##lowercase and sort the user input word
def simplify_entered_wo... |
I would like to get images from other websites.
This is my current method but I'm not sure if it is alright.
<?php
header('Content-Type: '.image_type_to_mime_type(exif_imagetype($_GET['url'])));
echo(file_get_contents($_GET['url']));
?>
If not, how should I do it?
|
Task
Write a program that, given the amount to make change for and a list of coins prints out how many different ways you can make change from the coins to STDOUT.
My approach
The number to make change for is N. Take one coin C and sum the number of ways to make N - C with the other coins. Add the number of ways to mak... |
Lately, I have been working on this Huffman algorithm and it is finally done, though I think it is improvable due to the fact that people say you have got to use two priority queues but I ended up just using one, so maybe it is even not correctly implemented.
Code:
#include <iostream>
#include <string>
#include <map>
#... |
I have a model called booking.
class Booking < ActiveRecord::Base
has_many :charges
def charge!
raise "Not active" if !active?
c = charges.create()
c.charge!
end
end
However I feel this is not optimal. For example, it would be nice to integrate the activeness checking into Rails' own validation syst... |
I shall make a JavaScript-function which does the same as PHP's array_diff:
http://php.net/manual/de/function.array-diff.php
Because it is intended to use the function as a (internal) library-function I have tried to catch everything which could possibly go wrong concerning incorrect usage.
Moreover I've tried to docum... |
I was trying to do a sample threading program, where the spawning of thread is in a while loop. I DO NOT want to generate multiple number of threads. The while loop should keep on running, irrespective of whether the thread completed execution or not. There is a call to the .get() function of the above thread within th... |
I had to build a responsive component which allows the user to display specific content in a page. I called it the contentToggler.
Here is my component in action
HTML Structure of togglers & contents :
On small screens : <select> with <option>
On big screens : <div> containing <buttons>
<select id="paymentMethodSelect... |
I'm using the following code to parse html, This code is working but since I'm new to JavaScript and working in alone project I would appreciate if you can give me some tips and feedback how can I improve this code,or it is fine...
The requirements are:
Insert a new script after given script ID(in the code after test... |
I'm fairly new to JavaScript and Node and am wondering if I'm on the right track.
Module file:
'use strict';
var chalk = require('chalk');
var config = require('../config');
var moment = require('moment');
var rp = require('request-promise');
var todayDay = moment().format('dddd'); // ["Monday"]"
var todayDate = mom... |
I'm adding an onclick listener to the whole document then checking the source of the click. If the source of the click contains the attribute data-widget I want to go to the appropriate action. I did it but I'm hoping for a more efficient way of doing things and if I can do without the self invoking function.
<div dat... |
This is my first Rust program. I have previously written a lot of Python, and some C. I would like some advice on whether I am doing things idiomatically, and any improvements I could make! I also appreciate any suggestions with regards to style.
The code takes two text files as cmd line args. One file contains an ... |
I'm learning bash and my goal here is from any repository on my computer to be able to type github and it will open the remote in a browser for me.
This works but I feel like I over complicated the remote=$(..) logic and arguably the get_ext() method.
get_ext() allows you to type github issues and it will open the issu... |
Recently I have been doing a bit of work with Contact Form 7 and Wordpress. I've begun looking at form validation using jQuery and I've been trying to write a script that is as efficient as possible.
I'm wondering if someone could take a look at my code here: https://jsfiddle.net/javacadabra/6mpo9h9z/4/ and let me know... |
This Greasemonkey script adds links to tags on StackExchange sites which allow for activating, deactivating and ignoring favorite and related tags by using UI components.
Since JavaScript is not my favourite language I'd be glad to hear what can be done more elegant, more beautiful, more performant, etc. (also by using... |
I am new in Go and for study I have to hold a presentation about concurrency in Go. I think the Golang Tour - Webcrawler exercise is a nice example to talk about that. Before I do that, it would be nice if anybody could verify if this solution fits. I assume it is correct but perhaps I have missed anything or any of yo... |
I have used a HashMap of ArrayLists to maintain the nodes at each depth.
Also i maintained a depth at each node in the binary tree by using a HashMap that stores . While traversing the tree in a breadth first manner, store the depth of each node(just one more than the depth of its parent) in the hashmap and add the nod... |
The task is to find the top two elements from the array without sorting. how can we achieve it? Can we use any DS to achieve this? Say tree? Please pour in your suggestions.
Between, iterative way of solving the problem is also one way. I have done that. Below is the code. I will also welcome if the below can be custom... |
I have the following code that will skip certain URLs if needed:
SEARCH = "inurl:index.php?id="
def get_urls
puts "Searching for possible SQL vulnerable sites, using search query #{SEARCH}"
agent = Mechanize.new
agent.user_agent = @user_agent
page = agent.get('http://www.google.com/')
google_form = page.form... |
I'm looking for general feedback on this module. Here is what it handles on the page:
This is a private "class" meaning none of its properties are available outside of it.
init is run at run-time. pre sets up parameters to be sent to the server via ajax and post receives the ajax response.
I can post the code for Cl... |
I have a program which is designed to be highly parallelizable. I suspect that some processors are finishing this Python script sooner then other processors, which would explain behavior I observe upstream of this code. Is it possible that this code allows some mpi processes to finish sooner than others?
comm = MPI.COM... |
I wanted to get some stats on who has done the most edits on Code Review, so I wrote the following query on SE Data Explorer. All improvement suggestions are welcome.
Note that I used a cursor to partition top users by year because at first there was a fundamental flaw in my logic trying to get the top users overall a... |
I am looking for feedback on my implementations of Queue, Stack, and LinkedList using Java generics. I would very much appreciate feedback on what I can improve and any errors I made.
LinkedList
public class LinkedList<T> {
private int size;
private Node<T> head;
public LinkedList() {
this.head =... |
As a first step in learning Haskell I am solving this problem, which involves finding the Rith-ranked numbers, given some input list and many Ri. In an imperative language I would make a zeroed array c of length 200, increment c[h] for each height h, compute cumulative sums of c and then binary search c to determine th... |
I came across a coding challenge that looked something like this (recreating from memory, sorry)
Suppose you have the following interface for a linked list. Implement an efficient and correct copy constructor.
template <typename T>
class SillyLinkedList {
public:
SillyLinkedList();
SillyLinkedList(const Sil... |
Define a procedure that takes three numbers as arguments and returns the sum of squares of the two largest numbers.
I'm using just the machinery that was developed so far in SICP to be true to the exercise. My method works as far as I can tell -- I tested it for a number of cases and tested different permutations of... |
I wanted a template for a service script that is versatile and easily configurable.
Along with producing similar outputs to the SSH and Samba daemons, I request the code to be as clean, simple and self explanatory as possible. Hence I removed all the comments.
Sample usage:
$ service mydaemon restart
mydaemon stop/wai... |
My getExtend() function, which will be included via require.js, has two inputs and one output:
HTML file content
config object which determine how to update the HTML, for example to create new script (as the first object in the array
extendedHtmlObject ) or update existing script content such as
attributes values... |
I made a function about random backgrounds
And those images will unique as possible. (Shuffle again after all gone)
My steps is :
Setup the array
Shuffle it
Do function (check if isset() so run on)
PHP :
$rand_image_ids = [1048,1049,1061,1064,983,972,964];
shuffle($rand_image_ids);
$rand_images_i = 0;
function rand_... |
This is a small socket library I made to avoid complicated C boilerplate code and several #includes for connecting sockets, bind, listening etc.
Please note that socket_create() does not support bind to specific IP addresses and that the IP parameter is ignored.
The only C++11 feature I am using is constexpr. Even thou... |
I have recently built a plain old Ruby program using TDD with RSpec to model this. I wanted to get feedback.
Repo
For the company whose application we’re looking at, order processing
looks something like:
If we accept an order over the web, then we have to wait for payment
to arrive, unless it’s a credit-card orde... |
I've been working on this pong game for the last 10 days, and I'd like to know of your opinions about it, what could I change to make my code better?
#include <stdio.h>
#include <allegro5/allegro.h>
#include "allegro5/allegro.h"
#include "allegro5/allegro_image.h"
#include <allegro5/allegro_native_dialog.h>
#include <... |
I'm currently writting piece of logic which copies entities from one user account to another. My current strategy in doing this is like that:
Consider the following code:
public class MobileOrderSettings:ICloneable
{
public long Id { get; set; }
public bool allowCash { get; set; }
public int deliveryPrice ... |
Recently I started playing a bit with Slim and what is making me confused is a necessity of container and middlewares hard coding. As because I am a staunch supporter of a dynamic loading I decided to write a piece of code for middlewares that suits my preferences. Considering my programing skills limitations - I am ... |
So I have some code which I created from the top of my head. But in all honesty I know it can't be the most efficient way of doing it.
I have some data in a file all positioned 5 values per line separated by commas (one line will be a specific object) dependent on the name of the item.
I know this can't be the best way... |
I'm fairly new to F# and have written a program to parse PLY files - this is however done in an imperative way with mutable values and as far as I know that should be avoided in functional languages.
The program works, but is the performance weakened by this imperative way of doing things? How is the coding style?
modu... |
Description:
Since the input array is sorted, we can take the middle element of the array to be parent and recursively do the same on the left and right halves to create left and right sub trees of the parent.
class Node{
int data;
Node left;
Node right;
Node(int x)
{
... |
Looking for some constructive feedback on Parsing an Address without using Regular Expression in C# for performance purposes.
My aim is to clean the data and to separate it into its respective fields: HouseNumber, Directional, StreetName, StreetType, Zip, City, State, Apartment
Example Input: 123 Main Street
Example ... |
open Core.Std;;
let print aofa =
let s1 = ( Array.length aofa ) - 1 in
for i = 0 to s1 do
for j = 0 to (Array.length aofa.(i)) - 1 do
printf "%d " aofa.(i).(j);
done;
printf "\n";
done;
;;
let rec fact i =
if i <= 1 then 1 else i * fact (i - 1)
;;
let rec permuta... |
I've recently started to check out Angular 2 and TypeScript that comes with it, and I guess I'm kinda into it. However I'm not too sure about the whole "TypeScript way" of doing things, specifically the typing of variables and such.
I wrote this simple modal component which displays a modal when the ModalApiService has... |
I want to clone a collection with the following method and I want to know if it can be optimized:
public T CloneCollection<T>(IEmployees employees) where T : IEmployees, new()
{
T collection = new T();
foreach (IEmployee employee in employees)
{
collection.Add(employee);
}
return collection;... |
I'm working on a language called grond (see it on GitHub); the compiler is so small it is included in this post.
My gut tells me that this code is awful, but it works. I am hesitant to change things to make the code better because generally, I have found that bad things happen when I "fix" something that isn't necessar... |
I have answered to a question on Stackoverflow where Andy struggled to cancel a Stream copy to file operation using the Universal .NET Framework:
Apparently, cancelling the cts CancelOperation token had not the expected behavior.
await httpResponseContent.Content.WriteToStreamAsync(streamToWrite.AsOutputStream()).AsTas... |
Given a string of length n, print all permutation of the given string.
The code bellow generates all permutations (with repetitions) for the given string and stores them in object res. Could you suggest ways to make the code faster (or a completely different algorithm written in R)? (For the "ABRACADABRA" word it tak... |
Just an idea I had for a Java exercise. Cracking a password like "testing" takes at least 15 minutes, so obviously it's not as efficient as it can be. What are your thoughts? I also never worked with multithreading, so I can imagine I could be doing things better there.
public class AlgoTester implements Runnable {
... |
I rarely see this kind of navigating on the web. But basically I load all the content in the background and then flip pages as needed while loading user specific data via ajax.
Are there any problems with this and in general?
/********************************************************************************************... |
I need to find the length of elements within a string and return it to the user.
What is the best way of simplifying this code to make the amount of string lengths equate to user input? Also, how can I replace string1 with the user input, such as "The length of string 'Dog' is 3"?
num_of_items = int(input("How many ite... |
I was just wondering how secure my code looked and if I'm overlooking any serious mistakes. Any suggestions/critiques are welcome.
This is my relevant login script.
login.php
<?php
if (!isset($_POST['remember']) && isset($_POST['user'])) {
if (isset($_COOKIE['remember_me'])) {
$past = time() - 100;
... |
The problem can be found here and is essentially asking us to generate J many numbers containing N many digits, where these digits have to be either 0 or 1. The catch is that the these numbers that we generate have to be composite when interpreted as being written in base i, where i ranges from 2 to 10, inclusive. Furt... |
After A ton of work I finally have a working Tic Tac Toe game that I am very proud of, and it works great. I would like some feedback on anything that can be improved/ needs to be changed.
I had a problem implementing my header guards. After I finished everything, my IDE automatically sets up #pragma once. After frustr... |
I have a search function in my class which checks various class property values for null or certain values and queries the database based on those properties. This how my function looks like now:
public object searchCustomerList()
{
object partner = null;
try
{
using (var rep = ... |
I recently joined the tex community and had quite a fun week texing. (I migrated this question to codereview, as it seems to be the better place for code-review samples). The result is some layout/format I would like to use for future theses/small-books. I did host the the whole thing here, and as others might like to ... |
How can I make the saving to the dictionaries more efficient as well as making my overall code more efficient?
import random
import sys
import shelve
def get_input_or_quit(prompt, quit="Q"):
prompt += " (Press '{}' to exit) : ".format(quit)
val = input(prompt).strip()
if val.upper() == quit:
sys.ex... |
I wrote this algorithm to rotate elements in an array. It's not very efficient, but it works. It has another disadvantage that it doesn't rotate right (it would be nice to pass it negative steps, for example).
def rotate_left!(array, steps = 1)
for i in 0...steps
first = array[0]
for j in 1...array.size
... |
I have an ArrayList which contains Strings with a size of 1000. I am looping through that ArrayList and finding words and trying to form a square from them. For example as follows:
C A R D
A R E A
R E A R
D A R T
The square must match left to right and top to bottom. So first left to right word (card) must match firs... |
My application needs to implement authenticated encryption using C#. There is a .NET class called encryptAndAuthenticate, but it is only supported on windows 8 or later, and I need the code to also work on windows 7. I created a class for internal use in my app that uses the encrypt-then-authenticate model. I use AES ... |
Here is my code:
def winnerchecker():
def player1win():
print '\n' * 5, name, "YOU HAVE WON! GG TO", xplayer
time.sleep(3)
raise SystemExit()
try:
if "1,1" in turn1l and "1,2" in turn1l and "1,3"in turn1l:
player1win()
elif "1,1" in turn1l and "2,1" in turn1l... |
Series post - I am reading through Introduction to Algorithms, 3rd Edition implementing each algorithm as I read them.
Pretty basic insertion sort. Only considering numbers initially - how could I make this better and/or have better tests?
def insertion_sort(numbs):
for cur_index in range(1, len(numbs)):
c... |
After seeing Tic Tac Toe in MVC, I attempted to create something similar. My program uses the Swing library and it's relatively simple. When I run the game, it's just a 3x3 grid with no extra features.
Can anyone give me tips on how to improve my overall MVC design / code? I did a lot of reading, but I sure I don't ful... |
I have a function that pulls data from a file or string literal in my case and returns them in either a list or a dict.
My concerns
I'm not sure if a function should have two different return types.
I feel like I'm repeating myself a lot.
If it is ok to return two different datatypes, how do you document that in the d... |
This is my first ever program in my first language, Python. I wanted to know how I could improve my writing style.
#USER: TCG
#Noughts & Crosses
#Header
header = '''
------------------------------------------
| |
| KNOTS & CROSSES |
| ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.