instruction
stringlengths
71
71.9k
Here's my implementation of a Stack in Java, all feedback welcome. import java.util.Iterator; public class Stack<T> implements Iterable<T> { private Node head = null; private int size; @Override public Iterator<T> iterator() { return new StackIterator(); } private class Node<T>{ ...
This is my implementation of the stack data type in C language. It is static meaning it does not grow in size. Any suggestions or feedback would be much appreciated. #include <stdio.h> #define MAXSTACKLENGTH 6 #define true 1 #define false 0 struct stk{ char content[MAXSTACKLENGTH]; int top; }; typedef struct ...
For practice in Python OOP (first time) and for some relaxation from trying to learn Serialization in Java, I decided to write a LinkedList in Python. Now, this class would be pretty useless, because in Python, instead of: (Java) int[] array = new int[size]; // initialization... // Now add an object to the end int[] ne...
I solved the problem but for two test cases, it's giving me timeout error. It's taking longer than 2 seconds on their servers. I tried using <ctime> to calculate the run time of the program and on my system, it's taking between 1.3-1.6 seconds. It's only giving me error for TestCases #9 and #10. The question is to find...
I was searching for a non-recursive odd-even mergesort implementation and found this one: Sedgewick R. The resulting sorting network is not an odd-even-merge sort network. When one draws a diagram of the pairs, it can be seen that too many pairs are generated and others are missed. So here is an image of a correct ne...
This piece of script will take one argument (file which contain list of ip, one per line) and convert it to its hostname. For now this will only work with IPv4. This definitely doesn't look good and I want experts to review it and suggest some good ways of coding it in Python. #!/usr/bin/python import socket import sy...
It is not related to GUI. I have a class with: Private List, which is edited inside the class. Open IReadOnlyCollection property for access to private List Public event for notification on List changing A list stores objects with properties. The class can changed an item's properties and notify about it. The user c...
This is my initial Facebook helper class. Is this code efficient or is there a way to improve this code? using UnityEngine; using System.Collections; using Newtonsoft.Json; using Facebook.MiniJSON; using System.Linq; public class FacebookManager : SingletonEternal<FacebookManager> { public string accessToken; ...
I'm trying the write a threadpool that can safely be added inside a signal handler or in code forked by multithreaded code. Are there any corner cases that would cause this code to fail? What could be done to improve this code? #include <pthread.h> #include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <s...
While I do know that there are many questions regarding "password generators," I have a different approach and would like to know if it is effective. 1) The below password generator takes on a different approach that other basic password generators, creating an empty string of x length, x being the desired length of th...
In the following query, I am fetching all the projects items with specific project id. At the same time, I am using a join in Select to fetch the delivered quantity of items of this project only. The delivered quantity join feels very costly because if I have 7000 items, it will multiply the iterations. In there any be...
Are there any advantages on using array_map & trim vs using simple str_replace? The input for both is an array of matched URL segments. I find it nice to be able to provide extra logic when using array_map but seems to be ~2 times slower. I did some trivial benchmarking for ($i = 0; $i < 10000; $i ++) { array_map(f...
In the standard library, there are no algorithms for element updates. This makes it unsuitable as a queue for a Dijkstra's algorithm, for example. Thus I implemented generic heap update functions with the interface in line with the standard library. Warning: the standard does not specify implementation detail of a heap...
I have written a server-side and the client-side of a chat application. I would like to improve it and I am unsure about my server construct and have absolutely no idea if there is a better way to do it. I haven't found anything on Google, therefor I ask you. The construct I have used is from a tutorial from Oracle I f...
I was trying to replicate Python's internal round() function. The program asks for a number, converts it into a float (catches the value error if present) and gets the absolute value of the float (to handle negative numbers). def rounder(): number = input("Give me a number to round off!: \n") #Makes sure you...
I want to improve the performance of this code: #!/usr/bin/env python # -*- coding: utf-8 -*- import numpy import random import math random.seed(42) class TrainModel: def __init__(cls, scheduling_interval, trains): cls.scheduling_interval = scheduling_interval cls.trains = trains class Train: ...
I was using dataTables.net's responsive plugin before this, and am happy to say that my (much simpler) code runs about 5 times quicker than that did. On my machine the fiddle averages about 50ms versus 250ms if I use DT responsive. Is there anything I should do to improve performance of my code? Can it be made better?...
This is an updatable priority queue. In contains an index (implemented as std::unordered_map) which maps a value to its position in the queue itself. The queue is implemented as a binary heap in a std::vector. This class stores each value twice: once in the queue and once in the index. Internally it uses a self-reporti...
I have a text file that contains 100,000 numbers from 1 ~ 100,000 in an unsorted manner (no duplicates). The name of the file is "IntegerArray.txt" My task is to count the number of inversions in the text file. An inversion is a pair of elements a, b where a comes before b, but a > b. Thus "1 2 3 6 4 5" contains two ...
Scenario: I want a task scheduler that enables my application to schedule some tasks in small time interval. I want to use it in my socket server application. For example, when the user connects to the socket application schedule some task in 15 seconds to disconnect user if no actions were made. Queuing task for spec...
I managed to make a simple function that calculates the Hailstone sequence of numbers and print it out, and I just done a calculator that grabs the number with the largest sequence smaller than n — and it may disprove the Collatz conjecture. Code with input numbers: #include <iostream> #include <string> using namespac...
I'm currently developing a TYPO3 Extension in PHP and developed a Hook. TYPO3 has the concept of Hooks where you can execute your own code as specific points. As defined in our definition of done, we want to PHPUnit-test our code base. I did some small tests before, so I'm familiar with the basic concepts. Below you ca...
I came across this SO question on why std::max_element requires a ForwardIterator (as apposed to an InputIterator). Having a max_element-like algorithm for InputIterator would be useful, as it could then be used with objects like std::istream_iterator or boost::transform_iterator. I came up with the following algorithm...
I am attempting to create functions for getting an algorithm, hashing and un-hashing a string. As it stands, it works, and very well. But, I feel this is not secure enough and someone could easily break it! Can someone help me to improve this? Code: <?php function HashIt($string) { $return = ''; $algo = GetAlgo...
I already posted this program numerous times, always surprised by the amount of improvement that is possible suggested by people here. Is it possible to make it even better, without nitpicking? At this point this is a special curiosity of mine =). # win sequences constant WIN_SEQUENCES = [[0, 1, 2], [3, 4, 5], [6, 7, 8...
I have made a tool that is pretty useful for me. I have made it open source on github. It is a server that listens for requests and returns an HTML static version of a single page app. It works with a convention that when the title of the page changes means that the new page is rendered. The way it works is very simple...
My AngularJs app is currently working fine. I'm working on modularity, refining my code design, and making it more readable. I have a app.js file that contains the module, the run block, and configuration definitions. By default Ionic uses the Ui-Router for route definition, so the routes are defined in my config block...
I have an class that cheaply imitates a lazy evaluation scheme. The class is for representing a file and additionally providing meta data on the file. Some of the meta-data can be expensive to evaluate so I only want to evaluate it when requested, and only evaluate it once. My implementation is such: All private membe...
This is a problem from my Introduction to Algorithms textbook. Consider the infinite sequence of numbers An|n>0 = (1,1,3,4,8,11,...) defined recursively as follows. $$ A_n = \left\{\begin{aligned} &1 && n = 1,2\\ &B_{n-1}+A_{n-2} && n > 2 \end{aligned} \right. \\ B_n = \left\{\begin{aligned} &2 && n = 1,2\\ &A_{n-1}+B_...
Am I commenting enough? Are my variables properly following correct styling format? Is there a more efficient way to code my "Label coloring" conditions? from tkinter import * import subprocess import re running = False # Infinite loop condition idle_status = 'To begin, please press "Start"' # Message for Idle Status ...
The purpose of this little program is to: Separate IPv4 addresses and IPv6 addresses Will be able to sort them even if the formatting of the input is not great Sort them into an order Print them into the system terminal in ascending and descending order I would like to know if you think the program what it is meant t...
I wrote a router class which accepts a URL and calls the appropriate controller method based on it. I'm a little worried about the amount of dependencies it has (eg ErrorController, RequestMethod, etc), because it might make reusing it in other projects difficult. It feels especially bad because a lot of the dependenc...
I'm trying to get into C, and I was wondering if I messed up regarding correctly implementing a linked list. node.h typedef struct node { int n; struct node* next; }node; code #include <stdio.h> #include <stdlib.h> #include <stdbool.h> // struct for linked lists #include "node.h" bool searchLinked(node* list...
After almost completely redoing the first version I think I finally have it. I still have a few things to add/change, but I think it's pretty good and safe. I've improved security features as well as overall functionality. I haven't run this program through pycharm yet, so there might be a few PEP 8 errors. It took me ...
I have a website, where one of the options that a user gets is to change their avatar. I would like to know if there is anything that I shouldn't or should be doing... So here is what I've got. Here is my PHP file that handles uploads: <?php include('./config.php'); $user = $_SESSION['user']['id']; $hash = rand...
I have written a class that is intended to execute a unit of work to be run in a separate thread. The intended use case for this class is running business logic off of the user interface thread so as not to lock it up while waiting for long running processes to finish. Here is the class: import javafx.beans.property.Ob...
I have solved this simple challenge on Advent of Code: Santa is trying to deliver presents in a large apartment building, but he can't find the right floor - the directions he got are a little confusing. He starts on the ground floor (floor 0) and then follows the instructions one character at a time. An opening...
This is a rather simple grade calculating application. Typical assignment or text book project. I've recently finished an introductory course to java, and have been continuously practicing by picking up random projects to see what I can do. I just recently made this Grade calculating project that I'm sure everyone is...
After studying several ways of doing OOP in JavaScript I think I finally came up with one that seems OK to me. Is it okay? Do you see some problems I can face by using OOP in JavaScript like this? JSFiddle test var Operators = (function ($, self) { var self = {}; //private var IPT_X = '#x'; var IPT_Y...
Here is a description of Project Euler problem 530: Every divisor \$d\$ of a number \$n\$ has a complementary divisor \$n/d\$. Let \$f(n)\$ be the sum of the greatest common divisor of \$d\$ and \$n/d\$ over all positive divisors \$d\$ of \$n\$, that is \$\displaystyle f(n)=\sum_{d/n}\gcd\left(d, \frac{n}{d}\right)\$....
I'm quite new to React and was working through the "Thinking in React" example, I noticed they used refs for updating state, but I also read on SO that using refs isn't that good in the long run, so I tried to redo this without using refs: JSFiddle var SearchBar = React.createClass({ handleChange: function(event) {...
This works, but I would like suggestions to improve it. For one I think the get posts shouldn't have to be repeated twice, but it only pulls the first two posts if I don't do it this way. Also, I think $incNum == 0 ? 'class="active"':'class' can be simplified, but if I take the second part out I get an error. <div cla...
I have the following code which switches between the states of hide() and show() of show prices button.I am aware about .toggle() in jQuery.But I couldn't find a workaround of it in this instance. When I click the button the <p></p> element is appended to .msg class in the div and when I click it once again it hides it...
This is my game manager script and is there anyway i can improve this code. using UnityEngine; using System.Collections; using System.Collections.Generic; using System.Linq; using UnityEngine.SceneManagement; public class GameManager : Singleton<GameManager> { public Game game=new Game(); public PendingGam...
I've written a generic implementation of the A* algorithm as a first Go program, since I had implemented that both in C and in Python before and Go reminds me a bit of both. I'm looking for general commentary on bad practices, specially concerning the following: References I don't think I've ever seen a struct being pa...
I have the following requirements: /* Collection Write a program that counts the number of unique words in a large text file. a] Store the words in a collection and report the number of unique words. b] Once you have created the collection, allow the user to search it to see whether various words appear in the text fi...
I am working with some Java code. Basically I have a wrapper class that holds a string and implements some of the many useful python string methods in Java. My goal here is to implement the Python method .ljust and my hope is to be as efficient as possible. Currently, I am using a while loop which I imagine is terrible...
I am creating simple quiz app in Django. It works, but I think that way I've done it is not the best. I have Exam detail view, which display questions related to that exam and answers for these questions. What are your suggests about it? I pasted only models, because I think that this is the problem here. from django.d...
Have you got any suggestions to improve this code? The idea is to generate a one-line string that is visually symmetric. Revisions at Github <p id="display"></p> <script> var display = document.getElementById('display'); var chars = [33,34,39,42,43,45,46,48,58,61,72,73,77,79,84,92,94,95,111,124]; var double_chars = [...
This question deals with the ability to construct a structure that is able to be easily iterated through. The problem: I have four different "boxes": Box A: Always has 1 apple and 1 pear Box B: Always has 1 orange and 1 pear Box C: Always has 1 peach Box D: Can have varying amounts of apples and oranges (0 - 10+) but ...
Problem Statement Create one form having following fields 1) Email ( with html5 email validation). 2) Password (It should take minimum 6 charactors ). 3) Your project URL ( with html5 url validation). 4) Project completion date ( with html5 date validation). 5) Current month ( with html5 month validation). 6) Current ...
This is a pretty basic bash script (3.2 on Mac). I am downloading 584 images from a site in order to create an album. #!/bin/bash urlFirst="http://150.216.68.252:8080/adore-djatoka/resolver?url_ver=Z39.88-2004&rft_id=http://150.216.68.252/ncgre000/00000012/00011462/00011462_ac_0" urlSecond=".jp2&svc_id=info:lanl-repo/...
From K&R exercise 1-21, Write a program entab that replaces strings of blanks by the minimum number of tabs and blanks to achieve the same spacing. Use the same tab stops as for detab. When either a tab or a single blank would suffice to reach a tab stop, which should be given preference? My solution: #include ...
I have written a small app that fetches news items from an endpoint and displays them in a grid. I used React to create components and use them throughout the app. This is the first thing I have built using ES6 - mainly for syntactic sugar. I tried to match the BBC News page style, so it should look very similar. It's ...
One of my latest refactorings for Rubberduck is Move Closer To Usage. The refactoring will take a field and move it just above the reference to it only if it is used in a single method, or take a variable declaration and move it just above its first call. As promised, I moved many of the duplicated support methods int...
CATS, willing to get a hold of all the bases, asked Dijkstra to give him a hand designing the most powerful algorithm to reach all bases with the least distance travelled. I tried to implement the Dijkstra's algorithm using TDD. This algorithm is designed to find the fastest route to reach all nodes of a graph. Right...
This is one of the first Verilog programs I have written. I have a Xilinx Artix-7 FPGA card. Right now I just have it transmitting an "X" every second. It works and I can see the result in my serial terminal. It uses a UART over USB connection. I'm just wondering if I can get some feedback on my code and if you see ...
If I am not mistaken, this method has a complexity \$O(N^2)\$: int[] exampleArray = { 4, 6, 2, 2, 6, 6, 1, 55, 55, 2, 5, 6, 90, 8, 8, 8, 10, 70 }; int k = GetMaximumCycle(exampleArray); public static int GetMaximumCycle(int[] anArray) { int length = anArray.Length; int result = 0; for (int i = 0; i < length; ...
In a small game project I'm using 'Init' and 'Shutdown' functions on Systems/Managers/Components to make resetting them easier without having to call the constructor/destructor. For example when reloading a level you can just call Shutdown and Init to reset to the starting state. A potential problem however I noticed i...
I have a block with an undefined data and a pair of REP [code]: arr: [ REP ["code1"] | 'something "f" | [ f | 3 ] REP [40 + 2] ] The pair can be everywhere in the arr. I replace every occurrence of a pair REP [code] with a value from evaluating the code. t: true while [t == true] [ f: fin...
I have been tasked with creating a report for a high-volume restaurant that shows hourly sales information for a given timespan. When generating this report for a single day, it's very quick, but when generated for even two days, the length of time grows tremendously. I was originally doing subqueries to get the data t...
This method finds the maximum in a binary tree. I have used generics to make this code more usable. However, I am not sure if I have written efficient and good Java code. This is a method inside a class using generics and implementing Comparable interface for the generic parameter E. private E maximumElement(TreeNode<E...
Here is a description of Project Euler problem 530: Every divisor \$d\$ of a number \$n\$ has a complementary divisor \$n/d\$. Let \$f(n)\$ be the sum of the greatest common divisor of \$d\$ and \$n/d\$ over all positive divisors \$d\$ of \$n\$, that is \$\displaystyle f(n)=\sum_{d/n}\gcd\left(d, \frac{n}{d}\right)\$....
Details about spring's caching framework are here. When I was reading this link, I thought the composite cache mentioned there was one that used levels of caching based on the order given to the constructor. On reading the documentation here, I realized that it was not so; this was so that different caching solutions c...
Originally, this script stemmed from a small script that watched stars and who made them, but a few days after launching, SE patched it so the people behind the stars aren't sent. Regardless, BigBrother, named after the character from 1984, had other functions, like monitoring obscene or unsightly chat messages and mon...
I have a question and want to know if my class is considered object oriented. class Player { private $db function __construct($db) { $this->db = $db; } public function set_player($name, $position, $number, $team) { try { $sql = 'INSERT INTO players SET playername = :pl...
I'm a beginner in Go, and just finished the Golang tour. This crawler is not the same as the one in the exercises in the tour but something I wrote myself. I am looking for suggestions for making it better in terms of idiomatic Go. package main import ( "fmt" "sync" "net/http" "log" "regexp" "i...
The following methods just write strings to the screen over time to make it look like a typing effect, instead of all at once. The only difference is the argument in the foreach loop. I end up having lots of similar methods like these. How do I refactor them? public IEnumerator TypeCharText(string message, Text textCom...
The latest refactoring for Rubberduck is Implement Interface. This refactoring will check whether the active class fully implements the selected interface by comparing the definitions. It knows the class based on the Implements statement, which looks like Implements IXyz. This extension method finds the interface bas...
In a couple of months I'll be part of a large(ish) project, and there's good chances my team will be a lot bigger, with at least 2 programmers (probably 3) and some 3-5, or more, consumers of the API we'll build (we're building a game, and they'll script high level logic using a scripting language we've yet to choose)....
I have an image and a palette that I want to apply on that image, that is, change all colors of the image to match the closest they can find on the palette. While I have multiple ways to do it, I want to let the user choose if he wants the algorithm to be more precise, or faster. The basic algorithm is this: int pIndex...
My code handles concurrent requests by waiting for the result of an already running operation. Requests for data may come in simultaneously with same/different credentials (including empty credentials). For each unique set of credentials there can be at most one GetCurrentInternal call in progress, with the result from...
This is my solution to Project Euler #92: A number chain is created by continuously adding the square of the digits in a number to form a new number until it has been seen before. For example, 44 → 32 → 13 → 10 → 1 → 1 85 → 89 → 145 → 42 → 20 → 4 → 16 → 37 → 58 → 89 Therefore any chain that arrives at 1 or 89 will b...
I want to place an element alternatively between any two elements of a list. l1 = list('abcde') fill = 'z' How it should look like: ['a', 'z', 'b', 'z', 'c', 'z', 'd', 'z', 'e'] My solution: fill = 'z' l2 = [fill]*(len(l1)-1) [x for t in map(None, l1, l2) for x in t if x] Is there a better approach, i.e. that doesn'...
I've written another diagnostic for VSDiagnostics that adds compile-time security for your formatting specified in a string.Format call. The exact scenario it guards against is when you have something like this: string s = string.Format("Hello {0}, I'm {1}!", "John"); This will throw a runtime exception because it ca...
I wrote a Vigenere cipher in Haskell, but I feel like I way overdid it. This is the second version of the program that allows custom cipher tables, removing the limit of just having letters from A to Z, and nothing more. I'd like to get some tips on what I could've done better, as this is the first program I've writte...
I've made vast improvements to my previous ls implementation, including: Added new flags: -g (omit owner listing) -o (omit group listing) -r (reverse with sorting) Removed a flag (which wasn't working entirely): -R Added long options for applicable flags (as defined) Defined a single buffer size Used more proper...
First of all, I didn't write this code from scratch, I'm pretty sure I took it from an online tutorial and modified it slightly to suit my needs. Can the code be improved in any way? I feel it's quite long winded and repetitive for a relatively simple task. function paginationAdvanced($select,$query,$per_page,$page,$ur...
I am trying to create a program to manage my Prosper investments for me as an intro to Haskell project. I created a post a few weeks ago for some of the simpler backend calculations: Recommend Next Note Purchase Now I've started working on the web APIs in order to retrieve my account information from Prosper. Though i...
For the online text-based browser game OGame I am working on an application with as aim to assist the users where possible, for this I have a server-side part and a client-side part, the respective repositories can be found here for the server-side part and here for the client-side part. The client-side part is impleme...
From K&R exercise 1-23, Write a program to remove all comments from a C program. Don't forget to handle quoted strings and character constants properly. C comments don't nest. My solution, #include <stdio.h> #include <stdlib.h> #include <string.h> #define MAXLEN 10000 // max input length int get_input(c...
This Python module contains helper functions to download the result page of SEDE queries and extract columns from it, most prominently: fetch_sede_soup(label, url): download the page of SEDE results, cache it or else use previously cached content, and return as a BeautifulSoup instance fetch_table(label, url): fetch a...
Maybe I totally reinvented the wheel, or maybe I've invented something new and useful. Can one of you tell me if there's a better way of doing this? Here's what I'm trying to do: I want a generic reduceBy function, that works like an RDD's reduceByKey, but will let me group data by any column in a Spark DataFrame. Yo...
Just for practice in the mathematical side of programming, I decided to rewrite the math functions, with the addition of the root() function, which the Math library does not provide, but can be easily done with Math.pow(x, 1 / y) where you want to find out x to the yth root. I also wrote this to review the Newton's Met...
One of the latest refactorings for Rubberduck is Extract Interface. This refactoring will take a class, display all public members, and allow you to select which members you wish to include in your interface. Next, it creates the interface, adds Implement <Interface Name> to the top of the file, and calls Implement I...
Built so that it doesn't depend on DLLs: http://s000.tinyupload.com/?file_id=25464905355948914118 My goal is to make a console calculator with a subset of the functions that are available on a scientific calculator. This source is WIP, the dependencies that are used by this are the ones that Visual Studio 2015 gives y...
This question is an improvement I did based on recommendations from this other question: Simple object-oriented calculator JSFiddle var Base = function (self) { // base class initialization self = self || {}; self.override = function(method, body) { var overriden = self[method]; self[method] =...
My goal is to make a consistent and easy way to determine how a function fails/succeeds. I'm looking for code review of my Status class for any bad practices, code that isn't thread-safe and general improvements and changes. For logging and debugging I always needed to know how a function failed and print this out as r...
Problem statement Write an anonymous function which take email address as parameter and returns true/false after validating the input parameter. Objective This assignment will help you to master the following concepts: function closures Solution <!DOCTYPE html> <html> <head> <title>Anomymous function</...
Problem statement Write an IIFE in which we have to validate the input provided from a form using closures. The form consists of name, email, phone, address in which name, email and phone number should not be left blank. Also validate that the given email is a valid email id using JavaScript. Objective This assignment...
I am currently working on a project in Java, and I use JavaFX for the GUI of the System. Currently, I am in the designing phase of the system, where I am designing the look of the system as well as setting up the basic functionality like navigation. I would highly appreciate it if someone can review my simple navigatio...
I have made a little Tic Tac Toe console application using OOP techniques and would love to get some advice and guidance on what I have done. I have tried to structure the program to be as organized as possible but I am sure there is a lot of room for improvement. main.cpp // TicTacToeOOPV2.cpp : Defines the entry poin...
I recently came across this SO question asking for methods to determine if a std::string represents an integer. There is also this SO question for floats. I decided to code up a few methods consolidating these questions. #include <string> #include <algorithm> #include <iterator> #include <cctype> namespace detail { ...
In constructing an answer to this question, I wrote a small debugger/simulator for the MAC-1 instruction set. There are a number of simulators already out there, but most are either too old to be compiled and run using a modern version of Java or C or C++ or they intended to exercise the machine down to the internal re...
In my iOS application, I've created a singleton class that reads a configuration plist file and provides accessor methods to easily retrieve the values: class Configuration{ struct Key{ static let searchRadius = "searchRadius" static let significantUserMovementThreshold = "movementThreshold" } ...
I wrote the following to check whether a string ends with a second string. function isEndOf(origin, target) { return (origin.substr(target.length * -1, target.length) === target); } Usage: isEndOf("A long time ago in a galaxy far, far away", "far away") This takes a substring with the size of the target string coun...
Just looking for some advice and I know using std namespace is bad but I didnt have the time to do all the using stuff. I want help on what here is good and what is bad practice :). #include "stdafx.h" #include <iostream> #include <fstream> #include <string> using namespace std; class file { public: file() = defa...
This code is made to generate a list of unique elements of the array made of the other two arrays. The fact that we need two lists to convert in two different array is part of the task. This code handles with the task, but there's a lot of global variables. As far as I know, it is not good practice. Tell me, please, ho...
This code allows printing in C with a style similar to C++ ostream. By using _Generic() (see GP()) to form a string specifier, the compiler handles the selection of printf() specifiers. No more mis-matched specifiers! Requested review goals: Design concept: Ways to improve? Implementation: What weakness & strengths...
I want to improve the performance of this program. count = 0 store = [] n = 9238899039 for i in range(1,n): if i*i*i <= n: count += 1 store.append(i) print count At the moment it is very slow. I need to find all cubic numbers up to n.