Aug 9, 2020
Sum of Digits of a Five Digit Number HACKER RANK SOLUTION
PROBLEM STATEMENT - https://www.hackerrank.com/challenges/sum-of-digits-of-a-five-digit-number/problem
SOLUTION ----
Functions in C HACKER RANK SOLUTION
PROBLEM STATEMENT - https://www.hackerrank.com/challenges/functions-in-c/problem
SOLUTIONS ______-----
PLAYING WITH CHARACTER HACKER RANK SOLUTION
PROBLEM STATEMENT - https://www.hackerrank.com/challenges/playing-with-characters/problem
SOLUTION ----------------------------
Aug 8, 2020
What is the Difference Between a Core and a Thread?
Think of the core as a person’s mouth and the threads as the hands. The mouth does all of the eating, while the hands just help organize the ‘workload’. The thread helps deliver the workload to the CPU more efficiently. More threads translates into a better-organized work queue, hence more efficiency in processing the information.
There’s a lot of confusion going around because of each manufacturer’s specific technologies. CPU cores refer to the actual hardware component. Threads refer to the virtual component that manages the tasks. There are a lot of different variations regarding how the CPU interacts with multiple threads. Basically, the CPU is fed tasks from a thread. It only accesses the second thread when the information sent by the first thread is slow or unreliable (like a cache miss).
You can find cores and threads in both AMD and Intel processors. Multithreading and hyper-threading are slightly different concepts. Hyper-threading is a technology that’s only available to Intel processors. While it’s still multithreading, it uses the threads more efficiently. That being said, AMD cores, namely the new (new-ish) Ryzen product line gets around this issue by adding more physical cores, delivering comparable results without having access to this technology.
Multithreading and Hyper-threading and Cache Misses
Cache misses are the processor’s attempts at reading memory loaded in the CPU cache. If the processor fails, then it has to access information from different types of memory modules, like RAM or permanent storage, which causes latency. This can definitely hinder your CPU’s performance. Running two parallel threads allows the processor to get information scheduled in the parallel thread, minimizing idle times. This increases performance regardless of what type of application you’re running, so it’s increased performance across the board.
What is Hyper-threading
Hyper-threading debuted in 2002 and was Intel’s attempt at bringing parallel computation to consumers. It’s a bit of a gimmick, as the OS recognizes the threads as separate CPU cores. When you’re running an Intel Chip, your task manager will show you double the number of cores and treat them as such. This allows them to share information and speed up the decoding process by sharing resources between cores. Intel claims that this technology can bring up to a 30% increase in performance.
How do CPU Cores and Threads work?
CPU cores are hardware. They do all the heavy lifting. Threads are used to help the CPU schedule their tasks more efficiently. If a CPU doesn’t have hyper-threading or multithreading, the tasks will be scheduled less efficiently, causing it to work overtime to access the information that’s relevant for running certain applications.
One core can work on one task at a time. Multiple cores help you run different applications more smoothly. If you’re planning on running a video game, for example, it will take a number of cores to run the game, while the other cores can run background apps, like Skype, Spotify, Chrome, or whatever else you might be running. Multithreading just makes processing more efficient. This, of course, will translate into better performance. It will also cause the processor to draw more power, but multithreading is already enabled on chips so that’s no cause for concern. While it draws more power, this rarely causes the temperatures to rise.
In a nutshell, when you’re considering upgrading, more threads equals more performance or better multitasking, depending on what applications you’re running. If you’re running multiple software at a time, it will definitely translate into increased performance. If you’re heart’s set on gaming, then multithreading might yield better results, but only with very particular titles.
Cores vs Threads When Gaming
Cores will always be more important when gaming. Gaming itself isn’t too much of an intense task for a processor. Even modern games can run smoothly on a quad-core, 4-threaded CPU, depending on the processor’s cache and clock speed. Threads are actually useful when you’re running multiple tasks. Say you’re gaming and you plan on streaming. A multithreaded or hyper-threaded processor will help you run the games within playable frame rates while also handling all of the encoding tasks that are associated with recording/streaming.
If you plan on recording game footage and uploading it to sites like Twitch.tv or Youtube.com, more threads help the processor run 2D video-processing software (such as Adobe Premiere, OBS, After Effects), so investing in a multithreaded, hyper-threading-capable processor makes sense if you’re planning on using your recorded gaming footage.
That being said, we’ve reached a crossroads in gaming. AAA developers keep pushing the boundaries of the PC’s current capabilities and keep designing games that are much more CPU-intensive. Games like the new Assassin’s Creed (Odyssey and Origins) are already pushing obsolete processors to their limit. The more ambitious game design means that the games will be more resource-hungry and less-optimized. While for esports titles (such as Overwatch and League of Legends) don’t really take advantage of the multiple threads, single-player, narrative-driven titles keep getting more and more ambitious.
Final Take
Basically, more cores and more threads will always mean better performance. Some productivity-oriented software, like video editing, will benefit more from multiple threads, while only certain games will take advantage of these features.
If your workload involves intensive tasks such as video editing, then multi-threaded processors are a must for you. Both Intel and AMD provide plenty of multi-core, multi-threaded, consumer-level processors. The Ryzen product line is more value-oriented, while Intel holds the flagship chips, namely the i9. For gaming, you can probably get steady 60+ frames with a quad-core with eight threads. If you plan on streaming or recording gaming footage, then you should definitely consider upgrading to a six or eight-core processor if you can’t invest in a dedicated system.
Aug 7, 2020
HOW DOES A VACCINE WORK
Vaccines are like a training course for the immune system. They prepare the body to fight disease without exposing it to disease symptoms.
When foreign invaders such as bacteria or viruses enter the body, immune cells called lymphocytes respond by producing antibodies, which are protein molecules. These antibodies fight the invader known as an antigen and protect against further infection. According to the Centers for Disease Control and Prevention (CDC), a healthy individual can produce millions of antibodies a day, fighting infection so efficiently that people never even know they were exposed to an antigen.
Unfortunately, the first time the body faces a particular invader, it can take several days to ramp up this antibody response. For really nasty antigens like the measles virus or whooping cough bacteria, a few days is too long. The infection can spread and kill the person before the immune system can fight back.
That's where vaccines come in. According to the Children's Hospital of Philadelphia Vaccine Education Center, vaccines are made of dead or weakened antigens. They can't cause an infection, but the immune system still sees them as an enemy and produces antibodies in response. After the threat has passed, many of the antibodies will break down, but immune cells called memory cells remain in the body.
When the body encounters that antigen again, the memory cells produce antibodies fast and strike down the invader before it's too late.
Vaccines also work on a community level. Some people can't be vaccinated, either because they are too young, or because their immune systems are too weak, according to the CDC. But if everyone around them is vaccinated, unvaccinated people are protected by something called herd immunity. In other words, they're unlikely to even come in contact with the disease, so they probably won't get sick. When it comes to vaccines, sometimes it can pay to follow the crowd.
Aug 6, 2020
Peaceful Warrior REVIEW
There's something sweetly sincere about how PEACEFUL WARRIOR sticks to self-improvement. Especially when you consider how often storytellers in and outside of Hollywood tend to conjure up simplistic antagonists -- aliens, drug smugglers, serial killers, vampires, orcs, hostile commie gymnasts from the USSR -- as obstacles for a flawed or uncertain hero to overcome. Dan's conflict is with himself, end of story.
That said, the dialogue is often hokey and preachy, the special effects and soundtrack music work a little too hard to tell viewers things they might have figured out on their own, and the film feels long at 120 minutes. On the plus side, Nolte gives a pleasantly low-key performance as the curmudgeonly Socrates; a lot of his Obi-Wan/Yoda/Master Splinter stuff is pleasantly unpredictable. Will watching Peaceful Warrior make you a better person? That's hard to say, Grasshopper. But it probably won't make anyone worse, and that's something of an achievement.
Families can talk about the goal of inspirational "mentor" tales. What do movies and TV shows that follow this kind of storyline have in common? Who are they trying to reach? Why do you think so many involve sports? Families can also discuss Socrates' sometimes-mixed messages about drinking, fighting, health and discipline, and being "in the moment." A lot of these points are alluded to in other martial-arts flicks, but they're often lost in a fog of kung-fu fighting.
The Pursuit of Happyness REVIEW
Will Smith shines in The Pursuit of Happyness ,a rags-to-riches tale about love, family, and pursuing the American Dream.
Smith portrays Christopher Gardner, a salesman struggling to make ends meet for his wife (Thandie Newton) and son (Jaden Christopher Syre Smith). As the family’s financial problems mount, his wife caves under the pressure and abandons him and their son.
Gardner’s luck goes from bad to worse as he and his son are evicted from their home and must survive on the streets of San Francisco. The father and son are forced to move from place to place seeking shelter wherever they can find it, even spending one night in a subway bathroom.
Things start looking up for Gardner when he applies for an internship with a stock brokerage firm. Though the internship is unpaid, one of the 20 interns will be chosen to stay with the company full-time. The ambitious salesman battles insurmountable odds to make himself stand out from his competitors in the hopes of landing the position.
Smith and his real-life son Jaden bring an emotional depth to the characters they play. The somber role of Gardner is quite a change for Smith, who is known for his less serious roles battling aliens in the Men in Black movies and portraying a matchmaking “date doctor” in the romantic comedy Hitch.
He tackles the role with a determined precision and turns out a spectacular performance, which is already generating talk of an Oscar. Though most scenes in the film have a very solemn feel, Smith’s cautious optimism and ambitious nature make us want to root for him to succeed. In a role that could have easily been played syrupy-sweet, Smith instead chooses to let his raw emotions shine through adding a layer of realism.
His son, Jaden, proves to be a natural as well. Portraying a child whose life and economic background is so completely opposite from his own doesn’t seem to be a challenge for the young actor. He seems to have a true understanding of the character’s emotional state and expresses it with ease.
Newton also provides a noteworthy performance as Gardner’s wife who becomes so emotionally distressed she makes the difficult choice to abandon her child. While promoting the movie recently, Newton said she wanted audiences to identify with her character’s profound pain rather than flippantly writing her off as an uncaring shrew. Her depiction of the troubled woman walks a fine line between the two.
While the story is a moving tale about a father’s love for his son and working hard to achieve dreams, it is more than that. Pursuit of Happyness is also a poignant portrayal of the problem of homelessness in our society. Perhaps what makes the film so powerful is that it is based on a true story. The problems that Gardner faces are problems faced by many in our society every day.
Anyone who is familiar with Gardner’s story, which was featured on the ABC news program 20/20 in 2003, will not be surprised at the way the film ends. However, I found myself wanting to see more from the latter part of Gardner’s life. I guess that is why the film is titled The Pursuit of Happyness. Though we do learn what became of him, we never get to see much of the joy that comes from Gardner’s struggles.
For this reason, the movie is not a feel-good picture that will leave you with the warm fuzzies. Instead, it is a touching fictional portrayal of a problem that is all too real. Chances are that this is not a film that you will quickly forget.