Jump to content

MikeD

Member
  • Posts

    216
  • Joined

  • Last visited

Everything posted by MikeD

  1. I looked at the picture and, even before reading anything, immediately thought "Artificial Intelligence". And sure enough that is the exact picture that appears on the book we used in that class! When I have the time I'll study that again and give the problem a go.
  2. Boas! Well, then, I look forward to solving it (after submitting a few incorrect answers and spending hours figuring out why)! Until the last problem I thought the test cases were provided by the MIUP judges after the competition. How do you come up with them? Is it random or do you spend some time designing tests for the corner cases? Yeah, I once tried to set up mooshak (a few years ago, out of curiosity since some of my classes used that for project submission) but I ended up just looking at some of the files because it was too bothersome to set up apache! But it shouldn't be hard to do, even to change the interface. And yes, many people have already worked on its security features. As for the learning problems, yes, I was thinking about some projects like enterprise applications or even simple games to teach architecture, abstraction and other software engineering techniques. But the evaluation of some of those types of projects are more focused on the quality of code rather than whether it passes all tests or not... Still, I'll probably take some of those algorithms lessons 'cause, like I said before, I already forgot many of them and could always use some more problem solving practice! I got stuck on the 3rd problem and then had to leave so I could only do the rest now. Better late than never!
  3. How's everything going? Do you have an estimate on when the new gateway or the next problems will be up? I mean, you made it through summer, don't die on us now!! By the way, since many people occasionally make mistakes when entering the results into the website perhaps you could move to something like mooshak for automatic evaluation (if that's not what you are already looking at)? When I read "learning problems" I immediately thought developing applications or games as if it was a project for a class (kinda like starting by defining data types, develop logic for each aspect of the app and link it all together). However it seems to be more like taking a step-by-step approach at problems similar to the ones we've been solving, right? If so, would there be room for the first kind as well? I'd very much like to help out with the problems, but I'm afraid I won't have much time in the foreseeable future between my dissertation and starting work.
  4. Yeah, ever since I changed my default language from Java to Python I've been spoiled in some ways! (arg[len(arg)-1] is so much better!)
  5. 1) Instead of arg.toLowerCase() == "whatever" do arg.toLowerCase().equals("whatever") otherwise there may be errors since == will compare references and not the actual content. Sometimes it works because it assigns the same object to the same string literals but not necessarily ( http://stackoverflow.com/a/513839 2) switch(arg.length() - 1) will search the cases for a number, not a character, you probably want something like switch(arg[arg.length() - 1]) (something like that)
  6. Decision Support Systems is, as many other fields in computer science, something that you learn in a semester long class and "that's just the basis" according to the teacher! In fact, we focused our studies in data-driven DSS. Keeping that in mind the summary that I can give you right now is: "A DSS is a management-level computational system that combines data, analytic tools and models to support making semi-structured or non structured decisions." A non structured problem is a new and unusual problem for which no algorithmic solution is known. (Taken from my teacher's book) First, you have to understand that the decision making process goes a little something like: Data --> Information --> Knowledge --> Action You also have to realize that any DSS must a) present a user friendly interface to the decision makers; b) present data/information in a familiar manner and c) be selective in the presented information (to avoid being bombarded with information. Usualy the IT and analysts will deal with the internals of the system and management will get a pretty report generated by the software! They also need to be as complete in terms of available models since you need to apply many to fully discover patterns in a body of data. DSS employs tools that range from data warehouses to collect and organize data and data mining algorithms to process that data and give you the information you need to make decisions, whatever your business may be. Data warehouses are somewhat like relational databases, except not! They both store information, but that's pretty much the end of similarities. Relational databases organize data as a bunch of entities that have attributes and the relations between them (hence the name), which is useful in an operational setting (a database of users and logins or books in a library). This model enforces functional dependencies that detect and prevent redundancy and avoiding anomalies when inserting, updating or deleting data and allows you to ask questions such as "What's this users password?" or "How many books in each category published after this date have the word 'X' in the title?". Data warehouses, on the other hand focus on data analysis rather than on the problems faced by operational systems in the day to day operations of an organization. They follow a multidimensional model that organizes data as a collection of facts (a sale, a deposit/withdraw, the temperature, etc.) associated with a set of attributes organized according to different dimensions, the most important of which being time. This allows the facts to be aggregated at different levels of granularity on one or more of those dimensions (time, location, etc.) by building cubes associated with a given fact whose edges represent dimensions. Then you can execute OLAP queries to ask stuff like "Which car sold most in this region of the country from X to Y day?" or "What was the cost of orthopedic treatments per age group for all years on record at this hospital?". Then we have data mining, a technology with roots in Artificial Intelligence, used to discover hidden patterns and relationships between the stored data and infer rules that predict future behavior. This process actually starts by fixing some flaws in the input data: missing values must be populated since many companies fail to build warehouses that store all the relevant information and data from different sources must be integrated into the same table to allow mining. Pre-processing also includes removing outliers to reduce noise in the data (using binning techniques) or removing attributes (columns) that are redundant or irrelevant (association rules). Some attributes cannot be processed by mining techniques (text or dates) and need to be transformed or discretized (if there are many possible values, like age). After all that you can finally apply mining techniques such as dependency derivation (e.g. association rules), clustering (e.g. k-means) or classification (e.g. decision trees, neural networks, bayesian networks). And then you classify the quality of the model you found by calculating the precision, sensibility, confusion matrices, lift-charts and many more methods. I skimmed over this last part because it would be even bigger than the first and you can google all these things on your own! This is what a (data driven) decision support system does, more or less! It's a complex system with many parts (data warehouses and mining algorithms being just two) and basically helps you come up with the models that best fit the available data so you can predict what's going to happen in the future.
  7. Actually, you'd be surprised with the level of thought that went into languages that see everything as lists. Just to (try) to entice you: a program in Scheme is... guess what? A list! Have you ever written a function that changed it's own behavior in runtime?! I have, in Scheme (it's called Racket now, whatever). And it was awesome! And other implementations such as common lisp allow you to change the meta-protocols that control how functions and structures behave (change what happens when you call a method in an object or use a struct as an operator). Furthermore, even without diving into all that fancy stuff the functional paradigm is very useful when introducing students to programming. I also started with Scheme but the point of the class was to learn the fundamentals (what's an algorithm, difference between recursive and iterative process, ...) and to write code using proper abstraction levels and techniques (for example declare functions inside others so they can only be used in that context). This. The language can change but the fundamentals are always the same. You'll also have things like Logic for Programming, theory of computation or discrete mathematics. Some of them are tough, but important nonetheless. But you should get informed about the choices you have in terms of institutions and degrees in your country/area. Search online for the descriptions of classes offered at each place and see if you like what's in the program or the objectives. My university has webpages for all classes taught in every degree and anyone can see information about it (except documents only meant for the actual students, but even those are sometimes public).
  8. Would you believe that I learned the basics about lambda calculus in a Natural Language class (Comp. Sci. master's degree)?! It is used to calculate the semantic of a sentence by attaching semantic rules to a context-free grammar. I wouldn't recommend starting with that article, though. There are a lot of concepts missing and the rules are not explicitly defined on how to perform beta-reduction or substitution. I did learn what a Y Combinator is and how recursion is formally represented (plus the if-else structures after some research on Wikipedia!).
  9. The Analysis and Synthesis of Algorithms classes in (at least) the two best Information Systems and Computer Engineering degrees taught in Portugal use the book by CLRS. Which obviously means I only read like a few pages of it and the rest was taught in class! I haven't seen the other one so I can't compare. What I can say is that the CLRS one helped me for the exams in the parts that I had most difficulty with (theory wise; I can't comment on the exercises because I used the ones we solved in problems classes but I think most of them were the same). I might actually have to read it again 'cause that stuff was kinda boring at the time I was taking the class so most of it is gone! Actually, most of the problems posted in the Problem Solving series in this board can be solved using techniques found in that book. One that I had completely forgotten about was the Disjoint Sets data structure. I had a flashback of those classes when someone mentioned it (it has been almost 3 years already)! So... yeah! Useful stuff and problems...! (Sorry I can't be of greater assistance talking about that book!)
  10. It's not the only method but would you trust on someone else's code for a space shuttle or would you rather spend more money and resources developing something mathematically proven yourself? When I said command line what I meant was it's not some super futuristic heads-up display like in the movies or videogames! It's also not as simple (or literal) as command line! Imagine having to type "dbus-send --print-reply=literal --system --reply-timeout=500 --dest=org.iss.transport.Soyuz /org/iss/transport org.sovietspaceprogram.Soyuz.DBus.Actions.CloseHatch int16:1 > /dev/null" (completely made up stuff right there!) into a shell just to close a hatch!! Well, there is information about fighter jets and military drones there, that's why I said that.
  11. Social networks (note that when I'm talking about these I actually mean any kind of service provided by a distributed system) also have to deal with reliability: if a server fails you have to use complex voting algorithms to correctly return some result, especially if you're dealing with byzantine fault tolerance (as opposed to silent fault toleration; (anyone who doesn't know what this is) google it to learn more!) or to elect the new primary server depending on who has the most recent copies of the data, etc. Who needs more reliability: a web service (social network or file collaboration system) or a space station (big machine floating in outer space with people inside)?! I'd also say the space station, but we could all be mistaken. I know that a single line of code in Java represents a whole bunch of Assembly instructions (especially considering that it's the java bytecode that needs to be emulated; java to bytecode expands the original code and then each bytecode takes several instructions to execute). It was a rhetorical question about the graph, I don't know if they counted it as being the same or not. I was also talking about developer testing. Everything from code coverage models or domain testing to method-, class-, inheritance-, integration-, regression-testing (and more). And I just remembered something else: most software for critical systems (even railroads or subways) is developed using formal methods of development. That means starting with the formal requirements definition, writing an abstract specification specifying the entities and the invariants that must hold throughout execution by using logic and maths fundamentals such as set theory and then progressively refining that specification until a code generator can produce the final compilable code. All steps must be verifiable and provable, thus the set theory involved. Such development techniques usually result in smaller code (and mathematically provable). Which would make reliability issues easier to deal with since you are investing time and money in developing it correctly from the beginning. You can search "formal methods" and "b-method" to learn more. (I had a whole semester with a class dedicated to software quality but most of it is fuzzy!! And the files are only available to students so I can't share here...) On the UI thing... I'm still not sold! All those stats are gathered by sensors and processed by the system but the UI only needs to display the number on a 7 segment display or somewhere on an LCD. Yes, some data (such as attitude) is usually displayed using graphs and there are a lot of buttons and (probably) menus, but I still think it is a very small percentage of the total code and smaller than what is needed for a website (considering all the scripts included for ads or API's such as JQuerry or Node.js). Neither Facebook, Google and the like nor the department of defense or whoever is responsible for keeping those stats about military equipment!
  12. What I meant was you don't need to upload pictures to facebook from a fighter jet. It's not mission critical. Yes, I am considering those factors. You don't need the same amount of security code in a fighter than on facebook (things like two-step authentication or privacy settings). It's not like a fighter is connected to the local cafe's wireless and you need to cipher you login info. Besides, most of those things will be implemented in specialized hardware (since most security algorithms are proprietary and secret and such operations need to be extremely fast). Which leads me to another question: is a line of assembly code the same as a line of C or Java code? Whereas I find it hard to believe a social network needs any assembly code to function I would bet a fighter, plane or spacecraft uses it extensively. As for the UI it's mostly all "command line" stuff. You don't need a beautiful HTML page with lots of CSS and javascript to launch a missile! Again, less code is better code. And I was not considering automated testing because it is not included in the normal operation of the system. The code for testing could be as large (or even larger) than the code for the actual system, but you only run it during maintenance operations. Again, you can run diagnostics on Facebook whenever you feel something is wrong but it'd not be a good idea to do the same on a fighter mid-flight. Anyways, that graphic is highly debatable. It is missing lots of important information and we don't even know if that is really true (there is a note that reads "some guess work, rumors & estimates"). If you keep adding modules, experiments and systems to the International Space Station it could potentially have more lines of Assembly code than some social network has Java lines of code.
  13. Why not just using an array whose elements contain a method that carries out the desired operation? That way you can always add more and can get the number of elements in the array. As an added bonus you no longer need to change the original method.
  14. I don't understand why you all think an F-35 or even a space shuttle should have more lines of code than facebook or any other website. In an aircraft or any other mission critical equipment where lives may be in danger (e.g. medical devices) you want a real-time system with extremely efficient code and no clutter. Just the bare minimum to perform the required tasks with extremely high precision. And you need to mathematically prove the correctness of most, if not all, algorithms if you want to send a space shuttle to outer space without it exploding mid-air because some value was losing precision throughout the calculations. The less code you have the less bugs you have to deal with. In facebook you are expecting the backend to manage your selfies and an array of other media types across several servers spread throughout the world in a secure fashion and to have a nice frontend to post your thoughts and upload your pictures and whatnot. Not to mention mobile apps, the code that goes into linking several platforms (you could upload pictures by sending them in an email to a specific facebook address not long ago, I believe), security, reliability, load-balancing algorithms for your data, advertisement, games (API's that enable these) and a slew of other "details" that need to be managed. And that's not counting each user's html page, otherwise the figure would be much higher (several orders of magnitude; besides, pages load dynamically, they are not static) but they should be counting (and probably are) the frontend (HTML templates, CSS, javascript, ...) that is needed to render those pages.
  15. I know there are lots of Youtubers using ads alone. Like I said, I don't think they should (more on that later). I believe someone else on this thread already said this: TV and radio have it figured out because there's no way (I think) of knowing if people actually watched the ad or not so these companies always get payed (depending on the share during that time period I suppose). YouTube (and the rest of the internet) is risky because you know exactly how many saw and/or clicked it. Which doesn't legitimize, in my opinion, ads as a source of revenue (ads at all). Forgive me (and point it out) if any of that information is wrong. Besides, most media outlets rely on other sources of income: paid journals and magazines, contests (the "call this number for 60 cents and enter to win this prize" (which makes a lot more money than I initially thought)), tax payer money (for publicly owned broadcasters), paid events, etc. And most are organized in groups where income from several events/mediums/products will finance (most of) the business. There is even a holding that belongs to the Portuguese Catholic Church responsible for 4 or 5 radio stations (2 of them among the most listened to (they mostly have pop music throughout the day!)). I wouldn't be surprised if some of the offerings to St. Jude (the patron saint of desperate cases and lost causes) ended up paying for Miley Cyrus's Wrecking Ball... And if the way of the future is to make a living off of ads then why not consider my earlier contribution of placing ads all over classrooms, hospitals, clinics, even surgery rooms? They sure get a lot of visitors. Suddenly there's no salary, only ad revenue. "This lung transplant is brought to you by: XPTO tobacco. It's the best!", said the free defibrillator before charging. (Ohhhhh, I'd love to see this in a Futurama episode... I mean, they have already incorporated ads into Nixon's speeches...) And maybe I could live on that mansion after all... Granted, the walls are covered in ads but, whatever. It gives an artsy feel. Heck, why don't we all quit our jobs and become youtubers? Apparently there is an abundant interest in videos of cats, fake yelling sheep (or funny animal situations of any kind), game playing, among many other exciting things. Why wouldn't we all be able to go to our grandparent's, make a 6 second montage of a chicken scaring a rottweiler and get insta-famous? Lots of ad cash await... The risk is exactly that people producing quality content are competing with "funny". And funny wins most of the time. At least on radio and TV they pay you X (fixed + depending on share/rating) for a Y minute spot. We don't know, nor will we find out, whether or not people would be willing to pay for product reviews, will we now, since they are already freely available. However, people do pay to learn. And they also pay to have things done for them, like 25$ to assemble the computer parts they just bought. If you publish a video and say "Click here to watch for free, with ads or over there to pay <more or less amount of money I would have gotten from said ads> and watch ad free", maybe I'd rather pay. The same with Google services: "pay 5$ a month for these services (+ x$ for additional obscure ones) and never watch a Google ad again". Perhaps it's just me with my "ads are evil" theory. And yes, many content creators wouldn't make it. And that's related to the perceived value of their content. If ads ceased to exist and Google did in fact put a price on their services I bet most people would pay since they have settled in that ecosystem. Would most people pay to watch someone play games all day? Probably not. Would they pay to watch Linus teach them how to assemble a computer and to be able to chose better the next time they shop for parts? I would think so. Many people are monthly contributors here on the forum already, paying up to 25$ (?) a month to support LMG in exchange for no banners and a sub-forum. Lynda.com teaches you, for a price, how to do lots of things that you could learn elsewhere for free and they aren't out of business. But ads exist, and they keep most of the content out there free. And that's why I am faced with the following choices: 1) Stop using any website/service that benefits from ads (yes, that basically includes all of Google and any webpage that has ads); 2) Stop using AdBlock everywhere, enjoy all the free services, be subjected to the will of advertisers and not complain when a video of a cat earns it's owner more than a teacher/surgeon/whatever earns in a year; 3) Keep using AdBlock and enjoying all the free services as a way of protesting the ad-centric business model, acknowledging, though, the hypocrisy in those actions (I don't really care for this one); 4) Pay for the services I want to use without ads. Oh wait... I don't have an option... 4) Not living on this planet anymore! Besides, so far this whole argument has been about how LMG makes most of its money from ads and sponsors and such. And even in a world without ads companies still need images, videos, reviews and that sort of stuff for their products, even if it's to show on their stores or web pages. Furthermore, when visiting LMG's "what we do" page, one can see that they are addressing companies that want to "deliver a message" about their products. We have seen some of those products, mainly for their client Func. My question at this point is: if ad revenue is so important that it's worth using the word scummy to classify AdBlock users (I wasn't even offended, the "ummy" at the end made it sound not so bad!) what happened to LMG's main business? Perhaps they could support The WAN Show and Techquickie and other videos without all the ads if their core business was more mature...? P.S.: Apologies for any lack of sense. It's rather late...! Feel free to call me out on any such thing. P.P.S.: Some people are trying to get this thread closed ("/thread"). Why? Why wouldn't you want healthy discussion to proceed? I am interested in the topic and I'm not talking to myself (much, yet!)... I just don't get it...
  16. But should people be making a living off of this ("this" being ads)? I think not. My point (as seen a few pages back) is that YouTube should be seen as a hobby, not a business. Simply because it's inherently free. You don't pay to watch videos nor to upload them. Google just decided to share some of its earnings with Youtubers to keep the platform growing and attract even more interest from companies that want to advertise. If your business/main product is content creation/videos (I am looking at you Linus!) I would expect you to actually sell them and not to just rely on ad revenue. If your business is retail and you use YouTube as a way to make your store and its products known, you don't have a problem in the first place. In conclusion: prevent ads => no revenue => paid content. Which I think is a better option. Ads are, in my opinion, one of the worst things that happened to the world anyway. Companies waste all their money in (sometimes excruciatingly bad) ads instead of focusing on the product and content creators, whose work is sometimes completely pointless, benefit from this because people without adblock consume their content as entertainment because it's freely available. And then we end up with surgeons making 300,000$ and let's players making 4M$. On the other hand, without ads, one could (maybe) theorize that surgeons would continue making 300,000$, LMG would still have paying subscribers that value his work and want to stay informed about the latest tech news and let's players would have an actual job because ain't nobody got money to pay to watch someone playing games and scream at the screen (they would much rather pay to play the actual game, perhaps, or maybe they see value in that and will also subscribe, which is fine). And companies would be "stuck" with using that money to reinvest on their products (oh noes!) or give to charity. I know that it is not black and white like I made it sound. The ad industry is so pervasive that it would have many implications that I am not contemplating. At this point it feels more like an utopia. And ads or no ads, there would still be a lot of disparity in income levels between essential and not-so-essential jobs. Essentially, like Professor Farnsworth once said (and the reason for my avatar): "I don't want to live on this planet anymore". After reading all the posts and taking a while to think about the state of the internet and the world (see above!) I could say I am faced with what some would call an "ethical pickle"! Like I said, I have been an AdBlock user for quite a while under the pretense that if content is free (as in I don't have to pay for it) I can consume it without ads and that ads are inherently bad. But then I have Google everything: mail, calendar, contacts, android, ... And Google's main source of income is... you know it: ads. Does that mean I must stop using everything Google related? What about Android, can I still use it because it's open source (and I already paid for the hardware)? Perhaps it's the same situation than LMG: if they want the consumer to pay for the content with no ads I would be happy to consider the situation, until then I will just use it with AdBlock. Or maybe I'll just give up on my "no ads ideal" and stop using AdBlock, effectively becoming a part of the capitalist world and embrace the ads and companies that pay for the services I use even though I never pay attention to them anyway! I'd really rather not give up on my ideals, but if the alternative is being a hypocrite because everything I do on the internet is funded by ads, I don't really have much of a choice, do I? So, in essence, yes, this thread was helpful, at least for me (and I hope for everyone as well). It got me thinking about a lot of things and, right now, I am strongly considering migrating away from Google and finding other services or making my own replacements (witch would have the added benefit of no "spying" by third-parties!). Or maybe I'm just over-analyzing everything due to being late at night (more like early in the morning). And I have other stuff to worry about right now like my thesis and job interviews! One last note: this is why I like discussions and don't understand people who say "we all have our opinions, they're not going to change, no point in arguing or debating let's just shut up". If you have an open mind, anything is possible (or something like that...). I, for one, am open to any criticism for what I've said. And I'm not sorry for how long this post is!
  17. I realize I am kind of late to this party and no one will probably read, but here you go anyways: It's funny how it has become acceptable that someone's source of income is ads. "Hey! I have produced high quality content with the help of my extensive crew and expansive equipment and posted it on a free website. Yes, it's free of charge. But if you don't watch all the ads plus the 10-16% of the video's time spent on sponsor integration (that recently ceased to be of tech-related nature) you are a scumbag." At least TekSyndicate spends only 0-5%. What kind of business is this, anyway, where you offer your main product/service free of charge? Wouldn't it be funny if you could go to the cinema free of charge, arrive 15 minutes late in order to skip the ads and have a Hollywood representative call you names for not sitting through them? Or maybe now we can all have free surgery as long as we have ads injected into our sleep during the whole procedure. (That's also funny, how we can sit idly by while Let's players and "pro" gamers earn win absurd amounts of money with ads and sponsors while people with jobs that actually matter for society are stuck with a small percentage compared to them.) At least NCIX and the like use Youtube as a tool to drive audiences to their store. Their main business is tech retail and Youtube is a way to inform people about their products. As a side project they even make small videos about current tech-related events, because they can afford it. On the other hand are people who are on Youtube as a hobby, which it is. They have their main job and produce some content when they have time because they are passionate about something or they simply want to goof around. Monetization is just a nice source of extra revenue to buy beer on the weekends! If your content is of any value to me I will have no problem in paying for it. If you're giving it away for free you can't come accuse me of stealing, pirating or in any other way harming your business because, honestly, you don't have a business. LMG productions are starting to look more and more like one of the privately owned public broadcast channels in my country where it seems like it is an ad distribution platform with some content sprinkled here and there to keeps us watching. Their business is ads, and it seems LMG's is too. (Right now I wouldn't be surprised if they came up with the same "Call XYZ number to enter for a chance to win 30.000$! 0.60 cents per call" scheme, every freaking minute) So, no. I will not disable AdBlock. However, if you decide to opt for a paid subscription or pay-per-video model, finally making tech content your product/service, I will evaluate the situation and subscribe or stop watching. Meanwhile I will contribute as I see fit through donations or campaigns. But I will not let you blast all the ads in my face while the companies that make them pay you and have you pass it off as your living.
  18. Not much to be said... Except that, once again, my code is not well organized and variable names could have been chosen better! #include <stdio.h>#include <stdlib.h>typedef struct queue_t { int id; struct queue_t *next;} Queue;typedef struct { int knows; int nfriends; int *friends;} Person;void queue_insert(Queue **q, int id) { Queue *aux; Queue *new = malloc(sizeof(Queue)); new->id = id; new->next = NULL; if(*q == NULL) *q = new; else { aux = *q; while(aux->next != NULL) aux = aux->next; aux->next = new; }}int queue_remove(Queue **q) { int ret; Queue *aux; if(*q == NULL) return -1; else { ret = (*q)->id; aux = (*q)->next; free(*q); *q = aux; } return ret;}int main() { int p, d, maxsize = 0, maxday = 0; Person *people; Queue *q = NULL; int i, j, today, size, day = 0, person, currPerson; scanf("%d\n", &p); people = malloc(sizeof(Person) * p); for(i = 0; i < p; i++) { people[i].knows = 0; scanf("%d ", &(people[i].nfriends)); people[i].friends = malloc(sizeof(int) * people[i].nfriends); for(j = 0; j < people[i].nfriends; j++) scanf("%d", &(people[i].friends[j])); } scanf("%d\n", &d); people[d].knows = 1; queue_insert(&q, d); today = 1; while(q != NULL) { day++; size = 0; for(i = 0; i < today; i++) { person = queue_remove(&q); for(j = 0; j < people[person].nfriends; j++) { currPerson = people[person].friends[j]; if(!people[currPerson].knows) { people[currPerson].knows = 1; queue_insert(&q, currPerson); size++; } } } if(size > maxsize) { maxsize = size; maxday = day; } today = size; } printf("%d\n%d\n", maxsize, maxday); for(i = 0; i < p; i++) free(people[i].friends); free(people); return 0;}
  19. Ok. I solved it late last night and then was too tired to post it here. It took me a while because I was getting 5 less deletable primes than the sample output and couldn't figure out why, but then I realized the test to exclude numbers like 10859 was excluding more stuff than it should. I did it in python because I wanted to put it together fast and that's why it isn't the most organized code ever. Then I translated to C to make it faster. I must say the python implementation of the sieve I used was found on StackOverflow (I liked the list comprehension better than all the nested for loops!). def sieve(n): np1 = n + 1 s = list(range(np1)) s[1] = 0 sqrtn = int(round(n**0.5)) for i in range(2, sqrtn + 1): if s[i]: s[i*i: np1: i] = [0] * len(range(i*i, np1, i)) return filter(None, s)delprimes = set([2, 3, 5, 7])for prime in sieve(10000000): if prime < 10: continue mult = 1 while mult < prime: rest = prime % mult testing = int(prime/(mult*10))*mult + rest if testing < int(mult/10): break if testing in delprimes: delprimes.add(prime) break mult *= 10print(len(delprimes))print(sum(delprimes))print() #include <stdio.h>#include <stdlib.h>#include <math.h>int* sieve(long n) { int i, j; long sqrtn = (long) sqrt(n); int* s = malloc(sizeof(int) * n); for(i = 2; i < n; i++) s[i] = 1; s[0] = s[1] = 0; for(i = 2; i < sqrtn + 1; i++) if(s[i]) for(j = i*i; j < n; j += i) s[j] = 0; return s;}int main() { int *s; long i, n = 10000001; long mult, rest, testing; long count = 0, sum = 0; s = sieve(n); for(i = 8; i < n; i++) if(s[i]) { mult = 1; s[i] = 0; while(mult < i) { rest = i % mult; testing = (long) (i/(mult*10))*mult + rest; if(testing < (long) (mult/10)) break; if(s[testing]) { s[i] = 1; break; } mult *= 10; } } for(i = 0; i < n; i++) if(s[i]){ count++; sum += i; } free(s); printf("%ld\n%ld\n", count, sum); return 0;}
  20. I only started when I got into university. So 17 years old (am now 22). Therefore, the first thing I could call decent is the project we did on our first programming class (Fundamentals of Programming), which was the mastermind game in Scheme (the GUI was provided by the teachers as it was not the focus of the project nor the class but we could add intelligence to the computer player for extra points).
  21. I didn't notice the "startx is not a problem" the first time I read the post! I assume, then, that there is no graphics drivers problem. Still, I'll leave my answer below.
  22. Have you ever heard of Thread-Level Speculation? There are a lot of runtime systems and compilers that do that and much more. You also have Transactional Memory systems and tools like OpenMP or even MPI to help with multi core/thread/chip processing.
  23. I can't research the specifics of how it is done other than what is said here: http://docs.oracle.com/javase/7/docs/api/java/lang/ClassLoader.html#getResource(java.lang.String) But that should be the case yes, since the folders in the jar are included in the classpath.
  24. Ups, double post. Having internet issues. On that note, excuse my brevity...
  25. Well, roughly speaking it's a way of getting a resource (e.g. file) based on the classpath instead of on a path (relative or absolute). When you call the JVM with a jar the classpath should be set so that the classes and resources can be loaded by the VM. Each loaded class has a class loader associated. You get that loader and ask it to load a resource, specifying the relative path to the root of the classpath.
×