#Problem 2
P2 = 0
fib= 0
f1 = 1
f2 = 0
debugP2 = []
while fib < 4000000:
fib = f1 + f2
f2 = f1
f1 = fib
if fib % 2 == 0:
P2 += fib
debugP2.append(fib)
print(debugP2)
print(fib)
The answer should be fib but it doesn't work for some reason.
So i'm trying to organize the main.js file for a website thats only about 4 pages. When I got on the project there was a bunch of inline javascript all over the place so i managed to get everything into one file but i felt like i was entering callback hell so i opted for a solution and was advise...
In spite of this moderator edit, which removed a picture that didn't add anything to the post besides a remotely on-topic caption about strings (the post was about string concatenation, the example with cats; the picture was a cat, with a string. haha...ha.), I promised myself (and the moderator ...
You will prompt a user for a month, a day and a year. You will then tell the user how many days since January 1 of that year the input date is. For example if the user inputs a 3 for the month, a 2 for the date, and 2000 for the year the program outputs the number of days as being 62. Note 2000 i...
My teacher wrote this, and I'm not sure if it works on her machine. I was supposed to add the line that says stuff = (char*)malloc..., which I believe is correct, but now I'm trying to test to make sure I did this correctly and it keeps skipping fgets despite the fflush.
int warmup2(void)
{
c...
@Malachi: As a matter of fact, JS was my very first language. And I haven't even taken a formal intro programming class prior to that. However, that was just a basic class and I haven't done anything in JS ever since. I'm not too interested in web development, though I have to be ready to learn anything.
I've just posted this solution in my review of @adrienlucca's question, which is to read three rows of six tab-separated doubles.
#include <fstream>
#include <iostream>
#include <string.h>
#include <vector>
struct Sexdoublet {
double x, y, d, m, c, t;
friend std::istream &operator>>(st...
I'm comparing a few micro-ORM such as Dapper and a few others and I just want to verify that when they say:
Performance of SELECT mapping over 500 iterations - POCO serialization
This is what they mean, right?
Stopwatch sw = new Stopwatch();
sw.Start();
using (SqlC...
I would like to drag and drop a div with width 60px (ccarcellbook) onto 3 divs with width 20px (ccarcell). Have got basic draggable function so that the big div replaces one of small divs, but dont know how to replace 3 small divs
also if I drop "ccarcellbook" onto 3 "ccarcell" the div id return...
I am a total novice to web development, but I am trying to be a WordPress developer and have been actively at it for some weeks now. All self-taught with the world's best tool as my aid: the internet. Anyway, I was hoping that you guys could look at my (no doubt: shoddy) code and tell me what you...
I recently worked with an architect who structured his base class like this:
public abstract class Base<T>
{
public abstract T Get(int id);
internal T InternalGet(int id, IRepository<T> repository)
{
// Do more magic
return repository.Get(id);
}
}
And then in the...
I am having a slight issue here, i am trying to think of a faster way of finding two elements from 2 different lists that match. The problem is that if i have lists which both have 1000 elements ( rules ) and the very last one [index.1000] matches then in order to find it i have to loop through b...
The overall question is: I need feedback on the security of the idea and the script. Do i need to do more in raw code, or is this ok,
taking account for my other informations.
1) Lets assume these following first:
All images are stored on a subdomain eg. images.example.com
The subdomai...
in an ios app I´m calling this function everytime the app gets opened in the applicationDidBecomeActive: function. I´m using ARC. My concern is it could create a memory leak because it´s creating new instances of UIViewControllers every time the app gets opened from the background.
- (void)showM...
I think he has some good insights but don't understand him at all when he starts about constructor functions. The following video for example:
At At 0:50:25 some of his quotes about constructor function inheritance:
This was the inheritance schema that was designed for the language
... I d...
The test tag was created very recently, and is so far tagged with one question:
Dapper - test code
Based on the title alone, well... the code within is meant to be test code. However, I feel the tag name is a bit ambiguous. Could the name also refer to unit-testing? What about the process of...
I've implemented the following code which allows me to bolt modules of code on to my core library via the prototype chain. It'q quite prescriptive so any user creating a module has to create an init method and also has to define a queue method:
(working fiddle: http://jsfiddle.net/wG9Pv/)
//Con...
I have 20 doctors.
Logic which I want to implement:
Each one of them sees calendar when can choose 3 shifts per month. When Admin lock a month doctor can trade his shift with another doctor.
When he click Trade trigger send_request action which should send trade request to all other doctors wi...
I am learning c programing, for exercise I found a task to solve. It is something like a game hanging where someone chooses a word and other person guess letters. I have to check how many given words could be a correct answer to the choosen word.
Input:
3 3 // numbers n and m n-number of words ...
As an exercise, I have implemented a linked queue whose enqueue and dequeue methods are synchronized. There is a Producer thread which keeps inserting elements into the queue as long as there are less than 10 items in it. When the queue is full, the thread waits. The second thread Consumer keep r...
This is the CalculatorAdvanced Kata from the Kata gem. I've just finished it and would love some feedback on my solution. Thanks!
CalculatorAdvanced Kata
Add Method
Allow the expression to handle new lines between numbers
- example: "1\n2\n3" computes to 6
- example: "...
I'm doing the codeacademy tutorial in which you make a simple Battleship game.
I have a function called "ask_input()" which asks the user to guess a column and row in which the target battleship could be. It seems that this function does not run entirely, since the "guess_col" and "guess_row" va...
Im a mediocre programer at best, and pretty terrible at javascript. But I have been tasked to create a google maps application. This application is driven by a dynamic report with a java layer on top of it, this java layer spits out generated google api javascript.
The problem I am running into...
I have a “featured projects” view that requires its subviews conform to a non-uniform grid: one narrow column with 3 items, then one wide column with 2 items, followed by another narrow column with 3 items. The width that is used for each subview is determined by the model’s display attribute. If...
this is the code that i have so far:
i for range(10)
j for range(10+i,end)
print(j,end="")
10
11,12
13,14,15
16,17,18,19
20,21,22,23,24
25,26,27,28,29,30
31,32,33,34,35,36,37
38,39,40,41,42,43,44,45
46,47,48,49,50,51,52,53,54
that is what im trying to create and im stuck and am unsur...
I'm trying to convert a std::string to integer with a default value if the conversion fails. C's atoi is way too forgiving and I've found that boost::lexical_cast is quite slow in the case where the cast fails. Its because an exception is raised I imagine. I don't have c++11, so stoi is out.
The...
How can i make this program running faster?
On enter i have string from console. for example "1 1 7 3 2 0 0 4 5 5 6 2 1" and on exit will be "6 20". Do you can read code and exchange my methods and function on something, that just will run faster...
import java.io.BufferedReader;
import java...