#!/usr/bin/env python3 from itertools import combinations import sys lines = set() vertex = set() if len(sys.argv) != 2: sys.exit('Usage: %s INPUT_FILE' % (sys.argv, )) try: with open(sys.argv, 'r') as stream: for input_line in stream: if not input_line.startswith('#'): drawing_line = tuple(input_line.split()) if len(drawing_line) > 0: lines.add(drawing_line) except (IOError, OSError): sys.exit('ERROR: unable to read input file') for l in lines: vertex.update(set(l)) def tuple_in_line(t, lines): return any(all(e in l for e in t) for l in lines) def valid_triangle(trio, lines): return (all(tuple_in_line(pair, lines) for pair in combinations(trio, 2)) and (not tuple_in_line(trio, lines))) triangles =  for trio in combinations(vertex, 3): trio = sorted(trio) if valid_triangle(trio, lines): triangles.append(trio) for t in sorted(triangles): print(' '.join(t)) print('Total: %s' % (len(triangles), ))
I played Far Cry 4 right after finishing The Witcher 3. It’s a nice game but nothing spectacular, so here’s my short review. Take into account I didn’t try cooperative mode.
Far Cry 4 essentially maintains the core game play present in Far Cry 3 and Far Cry 3: Blood Dragon. That means the game revolves around doing main quests for advancing the main game story and side quests for simply gaining points to invest in an abilities tree. While it has some RPG elements, every ability can be unlocked and used so it’s not a proper RPG game. It takes place in a large open map that’s revealed by exploring and by conquering radio towers, as well as clearing enemy bases so enemies mostly disappear from the surrounding area.
As stated above, if you played Far Cry 3, all of that will sound familiar to you: it’s the same. Different map, different main story, different characters and locations but the same core game play. Some game play elements have been subtly polished here and there without any major changes, while some new vehicles, enemies, animals and traveling mechanisms have been introduced.
I definitely like the story in Far Cry 4 more than the one in Far Cry 3, but neither of them are brilliant. It also follows a recent trend seen in other games were the endings are not exactly the same depending on a few important choices made during your adventure, with no ending being completely “good”.
Its game play low points are similar to the ones I found in Far Cry 3. In my opinion, there’s too much money and too many treasures in the game. Having a limited-capacity wallet can be a bit frustrating sometimes for a completionist player like myself. Learning from the previous franchise entry, I didn’t buy treasure maps and didn’t get obsessed with clearing every chest mark appearing in the map.
Again, there are also too many people and wild animals for such a small area. It’s almost impossible to travel from point A to point B without encountering a so-called “karma event” (good guys needing your help in a skirmish with bad guys) and facing several predators. It can be annoying and time-consuming, specially if, from time to time, they manage to seriously injure you or even kill you. Your safe bet becomes traveling using vehicles, which is usually faster.
Finally, the game is too easy, a common problem with recent titles in this game series. It gives you easy, medium and hard difficulties. I played in hard mode and it’s game over after completing less than 1/3 of the game. Once you have a silenced sniper rifle, the recurve bow and a silenced assault rifle or SMG you’re a lethal and invisible ninja, and even conquering fortresses (the most heavily-guarded enemy bases) is a trivial matter, so you may have to set your own challenges.
Don’t get me wrong, game play is entertaining and I’d like to emphasize, like I did for Far Cry 3, that I like the controls a lot (except the long key press for healing!) and the “physical behavior” of your character when it runs, jumps, grabs ledges, vaults over obstacles or slides down slopes. Being able to attack enemy bases while riding an elephant is interesting and fun.
Technically the game features some improvements, with more detailed textures, better lighting and weather effects and more polished geometry, but without drastic changes. It ran pretty good for me, with some very occasional, and not easy to explain, dips below 60 FPS, but I decided to stay away from the demanding TXAA anti-aliasing mode, using SMAA instead. UPlay is still a liability and the lack of a quick save key is an annoyance I’m starting to get used to in Far Cry titles.
Technically, I’d say the game is an 8 or 8.5. The game play is a solid 7.5 or 8 and the overall score is about an 8. If you still haven’t played it and find it on sale, I recommend you to grab it. If you didn’t like Far Cry 3, take into account Far Cry 4 is just more of the same. Blood Dragon is still my favorite Far Cry title to date, followed by the first Far Cry, but I haven’t played Far Cry Primal yet.
I upgraded my computer yesterday to Fedora 26 in some mere 20 minutes. It’s been the smoothest Fedora upgrade since I started using this OS. I’ve found nothing has broken or stopped working or requiring adjustments on my side. I decided to go for it seeing there hadn’t been major upgrades to Xorg and the kernel was the same (4.11.9). Naturally, Fedora 26 has many under-the-hood changes like the upgrade to GCC 7 and also a new version of Gnome, but I run i3.
A few weeks ago, after reading the insightful post “Most of the web really sucks if you have a slow connection” from Hacker News, I decided to give up some features in this blog to make it much lighter on resources.
The biggest change is dropping web fonts. In my Linux system, the blog looks essentially the same because I have the selected fonts installed, but external visitors may find everything looks slightly different. As part of that change, I also stopped using Font Awesome for the four icons at the top, replacing it with Unicode characters.
These characters look different depending on the web browser and platform. I settled for U+1F3E0 “house building” icon in the “Home” link, U+1F5C4 “file cabinet” in the “Archive” link, U+1F4F0 “newspaper” in the RSS feed icon and finally U+1F464 “bust in silhouette” in the “About me” link.
The icons look colorful and crystal clear in Chrome, Firefox and their Android variants, but a bit dull in Internet Explorer and Microsoft Edge. I asked a friend to let me see how they looked in an iPhone and they were OK. Using Internet Explorer 11 on Windows 7 from my work computer results in a very confusing newspaper icon and a missing file cabinet icon, but it’s a small price to pay for the space and bandwidth saved. I’m sure my site is now readable for more people around the globe thanks to being lighter.
It’s been a while since my previous long post. Apart from “routine” tasks like watching my son grow, taking pictures of him and working in my day job, the lack of content is simply explained because, apart from keeping my Fedora installation up-to-date and making sure my personal data is properly backed up, almost all the time I’ve spent at the desk of my home computer during the last two months has been playing The Witcher 1, 2 and 3 in succession, in what has been an incredible gaming journey. It’s hard to sum it up but I’ll try.
The Witcher game series revolves around the adventures of Geralt of Rivia, a so-called witcher in a medieval fantasy world. I’ll tell you soon what a witcher is. The lore and universe background is revealed step by step as you advance in the games and I don’t find it easy to explain in a few words to anyone asking me what the games are about.
The games take place in a fictional world that had been inhabited by elves, dwarfs and gnomes until a phenomenon called “The Conjunction of the Spheres” took place several centuries in the fictional past. When that happened, beings from other “worlds” (universes or planets, it’s not clear nor important) were magically and accidentally transported between these worlds and mixed up. Humans and other beings ended up in the game world when this happened. These other beings are mainly “monsters”. Think of them like animals and creatures from different worlds, with some of them being rational and very powerful, like higher-order vampires.
At some point in time, monsters had become so problematic and threatening that some humans decided to use alchemy, magic and training to create witcher schools. Places were, without spoiling the plot too much, humans are trained and mutated to gain superhuman abilities (far from superhero abilities) allowing them to fight monsters effectively. When they complete training, they travel the world accepting contracts on killing monsters, becoming professional monster-slayers. For that, they can count on their superhuman abilities and senses, a vast knowledge on many types of monsters, a set of armor, a steel sword, a silver sword and basic notions on magic and alchemy. And that’s what a witcher is and what Geralt of Rivia is: a professional monster slayer from the school of the wolf.
With that starting point, the trilogy follows chronologically and the game plots usually touch on politics, war, romance and, of course, killing monsters. Gameplay-wise they are real-time RPGs played in third-person view.
The first game was released in 2007 and it’s a bit different from the other two. It’s probably the worst game in the trilogy but it’s still, in my opinion, a nice game. It serves as a good introduction to several characters in the game world, including Geralt and Triss Merigold, but it does have some rough edges and aspects that were improved or completely changed in later games.
Combat, for example, is radically different in this first installment. Geralt cannot jump or dodge attacks explicitly, and combat revolves around choosing a combat style (fast, strong or group depending on the type of enemy and situation) and clicking on an enemy so that Geralt gets close to it and starts attacking. Attacks are not based on button mashing, but on resisting that urge and waiting for Geralt to complete an attack movement. At that moment, the on-screen cursor will change shape for a second or two indicating you can click once again to chain a second attack creating a combo. As you progress through the game and level up, you acquire talent points that can be spent in a talent tree to learn new abilities. Some of those abilities add a third, fourth or fifth attack that can be chained to form longer combos with increasing damage output. Others improve your chances of dodging and parrying enemy attacks, which happens automatically as I said before, or improve your chances of causing special effects on the enemy like stunning them, making them bleed or knocking them back.
With that in mind, combat in The Witcher quickly becomes a real-time game of numbers: choosing the proper enemy to attack, choosing the right style, drinking the right potion or coating your blade with the right oil to maximize damage, while spending points on useful abilities. Sure, positioning yourself properly in the battlefield is important, as is fleeing away to recover health when you’re hit hard, but those are secondary aspects.
As I mentioned previously, the game has some rough edges. For example, the talent-acquiring system divides talents in three categories: bronze, silver and gold. Normally, acquiring a silver-talented ability requires having developed a previous bronze-talented ability, and the same goes for silver and gold. When you first level up, you are only given bronze talent points to spend. As you progress and keep leveling up, the mix of talent points varies. It’s a way a bit too complicated of forcing you to decide where to spend points, knowing you’ll eventually run out of bronze talent points to spend and get yourself locked out of certain parts of the ability tree.
Another rough edge is the unclear way some game mechanisms work. For example, the way silver swords are crafted. To craft a silver sword, 3 runes of the same or different types must be combined, resulting in swords with different stats depending on the rune combination. After you craft it, the crafted sword will be placed in the silver sword slot in your inventory, replacing whichever sword you had there. The original sword is lost, giving you the impression your sword is modified with the runes instead of the new sword being created from scratch. As a player, you may also wonder if the base sword you’re using (none in reality) plays a part in the stats of the new sword that has been created. The mechanism for steel swords is different, which only adds to the confusion.
But, perhaps, the roughest edge is the way quests and chapters work. The game is divided into chapters, with each chapter taking place in a different “map”. If you progress too much in the main quests, the chapter will end and action will move to the next chapter with no possibility of going back to the previous area. There’s no warning to the player this is about to happen, and it happened to me in the first chapter making me leave many side quests unfinished. Also related, your inventory space is limited but extra items can be stored in an unlimited storage area that’s normally accessible at taverns and inns, teleporting with you between chapters. In the final and decisive chapter, with no previous warning and only small dialogue hints, you’re only given access to the storage space right before the main action starts, leaving possibly valuable potions, oils and other items unused. You may have been accumulating them for the duration of the game with the goal of using them in a possibly harder final chapter or battle.
Despite those rough points and other minor ones like some boss fights being noticeably more difficult than others, or the lack of some proper transitions between game action and cutscenes that sometimes make them surprising and disconcerting, playing The Witcher is quite fun. In technical aspects the game is not remarkable but the gameplay is solid. If you press me to give it a score, I’d say it’s about an 8 and, if you plan on playing any The Witcher games, you won’t waste your time trying this first one.
The Witcher 2
The second game is a direct sequel taking place mere weeks or months after the ending of the first one. It was first published in 2011 and it’s a very different game, which can be appreciated in both the gameplay and graphics. Visually, The Witcher 2 is a huge improvement over its predecessor and thanks to its high-quality textures, geometry and effects it has aged very well, in my opinion. The game has a nice plot with well-developed characters and a much more intense focus on the game world politics and fights for power, but without abandoning romance and monster-slaying elements at all.
Every rough point in the first game has been fixed and polished. The game is still divided in chapters, with each chapter taking place in a different area. But, this time, you get a proper warning when each chapter is about to finish or an important event is about to happen that may affect your ability to complete secondary quests. The are less chapters and areas but they’re more varied and beautiful. The crafting mechanism is improved and every gameplay aspect related to it is now perfectly clear to the player.
Each time you level up you’re given a point you can spend in the abilities tree, to improve an ability you already have or to gain a new one. This is a much simpler mechanism compared to the first game and more in-line with what other games do. A level cap forces you to choose only part of the tree instead of being able to develop every ability.
Talking about level caps and sidetracking for a moment, many games have them but they’re not written explicitly and I don’t really know why. For example, The Witcher 2 has a level cap of 35. I don’t think it’s a bad idea to give this information to the player in advance. When your current level is reported in a screen somewhere, the game could report it as level X/35, for example.
Combat mechanics change completely compared to the first game, and The Witcher 2 is a proper action game in that aspect now. Geralt still can’t jump, nor fall from edges, but he can dodge by performing a roll, perform fast or strong attacks with different buttons and a single button press roughly corresponds to a slash, so you know have almost complete control over the physical behavior of Geralt. The combat mechanics are more similar to other games like the Batman Arkham series or Dark Souls. If I had to choose the best controls of the trilogy, I’d choose this game. They’re responsive, action based, the movement set is varied enough and Geralt’s behavior is almost always what I expect. I only miss being able to jump, but it doesn’t bother me much.
Compared to the first game, inventory space is now replaced by a weight limit and, just like in its predecessor, managing this restriction is a frequent task, but not too burdensome. The teleporting storage mechanism makes a comeback and allows you to save interesting items for later use if you don’t want to sell them.
Another similarity to the first game is the way equipment improves. It’s not directly related to your level but to the area you’re currently at. New areas introduce more powerful items and equipment, inside treasure chests or as recipes that can be found or bought. Some of those recipes are expensive or require crafting elements that can only be obtained after completing a given secondary or main quest. It’s nice and balanced. Your improved equipment, and abilities as you level up, are matched, to maintain some balance, with new types of powerful monsters or larger groups of them. Monsters don’t have a visible level and equipment doesn’t have level requirements either. I think it’s a mechanism that works quite well in practice.
If the first game was an 8, The Witcher 2 is a nice improvement and I’d easily give it a score of 8.5 or 9. Totally recommended as it also introduces more characters and events that will play a major part in The Witcher 3.
The Witcher 3
The Witcher 3 is, again, a sequel to The Witcher 2 taking place a few months after the end of the second game. What can I say about The Witcher 3 that hasn’t been said before? Not much. The Witcher 3 is a superb game and, while not perfect, to me it’s easily a 9.5. Huge, long, detailed, it feels as if The Witcher 1 and 2 were mere steps in raising up enough money to be able to put it to work in such a magnificent title. The Witcher 3 is, no doubt, the witcher game CD Projekt RED wanted to create since the beginning, the best goodbye you could imagine for Geralt, and everything you could hope for in a witcher game.
Visually it’s simply impressive. You only have to find any videos online to see how it looks, with the grass and trees moving in the wind. I sometimes found myself stopping for a moment at the top of a hill and taking a few seconds to observe the view. I distinctly remember the first time I had to go to Oxenfurt, the second biggest city in the game, and emerging from behind a small hill to a view of the city from above, that only got better as I crossed an elevated bridge to cross the city walls while I observed its port below. Many screenshots have been taken from the incredibly beautiful region of Toussaint in its Blood and Wine expansion, but my favorite location are actually the Skellige isles with its coastal villages, its mountains and cliffs, clear water and snow. You can almost feel the cold when it snows and smell the salt when you’re on a beach. And, when I enter a big city or watch NPCs living in a small town somewhere, all following their routines, technology limits non withstanding, I feel it’s the most “alive” universe I’ve experienced in a video game.
So enough daydreaming. Gameplay is amazing. The story is long and good, and most major characters, both old and new, are very well developed. The biggest change from previous installments resides in what leveling up implies. You, again, gain points that you can invest in a “tree” of abilities but now enemies also have a level, and equipment has a level requirement with a direct influence in its stats, such as protection or damage dealt. Equipment does not level up with you and has to be switched for better gear as you advance in the game if you want to survive without problems. This is similar to Borderlands, to name the first title that comes to my mind with similar mechanics. I must recognize I don’t particularly like them but I concede it’s fair and it works perfectly.
Sidetracking again, I like the Dark Souls way better. In it, your character has points in different abilities and weapons scale with some of those abilities. So as you level up, the weapon levels up with you. In addition, you can upgrade your weapon by modifying it and that improves both its base damage as well as its damage scaling. However, I understand such a mechanism is more important in that game because each weapon has a different move set and mastering a weapon takes some effort, while in The Witcher 3, all swords are handled the same and your move set and timings don’t change.
The weight limit carries over from The Witcher 2 but it’s been relaxed a bit and not every item has weight. The storage area is also back and works the same.
The second major change is that, despite the game story progressing in chapters or acts like its predecessors, with some of them taking place mostly in a specific area, you can always go back to previous areas and travel between zones. Maps can be so large that a fast-travel mechanism has been implemented allowing you to travel between designed locations. You can also travel on horseback and sail on a boat.
The crafting mechanism has been improved, augmented and expanded, with the possibility of dismantling items to obtain lesser ingredients or removing upgrades from weapons. Finally, the mini-game changes from dice poker to Gwent, a not-so-simple but incredibly fun card game with collectible cards.
Geralt can now also swim, jump and dodge hits in addition to rolling away, or even shoot a crossbow. For the first time I felt my 3-button wheeled mouse and keyboard were lacking keys to bind to the vast array of possible actions. That’s why I said I actually prefer the controls from The Witcher 2, even with the restricted action set. Geralt’s response to input was altered again in this sequel and, after a few user complaints, an “alternative” movement mode was added to the options menu, making the feel closer to the second game. If you play The Witcher 3 right after The Witcher 2, you’ll probably like the alternative movement mode, so don’t forget to try it out. Just to nitpick, sometimes the way Geralt moves feels a bit robotic and unnatural, specially when jumping.
But those are, like I said, minor faults that barely diminish the quality of a superb game. I’m a completionist and a slow player, and I spent around 200 hours playing The Witcher 3 and its expansions, “Hearts of Stone” and “Blood and Wine”. It does feel like a journey, specially after playing its two previous installments, and I felt sad it was over but too exhausted, in a good way, to tackle “new game plus”. I highly recommend playing the trilogy and savoring it like a fine bottle of Sangreal from Toussaint.
Time to close the review. Wind’s howling.
How many triangles can you see in this image? It is said that only those with IQ 120 or above can find 18 triangles pic.twitter.com/dDPpzk0L3B— People's Daily,China (@PDChina) December 7, 2016
Apart from the bogus IQ statement, it offered me the chance to revisit my old piece of code that brute-forced the problem easily with a few lines of code thanks to the amazing speed of computers today.
I reworked the code by using
itertools.combinations instead of custom code,
removing a lot of boilerplate and improving the code in general and using Python
3 instead of Python 2. The result, in the public domain as the previous ones:
If problems were larger, we could generate graphs with all existing 2-vertex and 3-vertex connections beforehand and enumerate triangles using that knowledge instead of just brute-forcing the problem by generating all possible triangles and checking if they’re valid for the given drawing.
Reminder: to input data to the program you need to enumerate every vertex in the image by hand (a vertex is any point where two or more lines meet) and finally list the lines in the drawing, one per input line as a list of vertex separated by spaces. If in doubt, read my two previous posts on the problem.
In the Twitter image, like other replies said, there are actually 24 triangles.