Thursday, April 05, 2018
I just wanted to ask, what's up with the 2010-quality prizes in algorithm competitions?
Friday, May 13, 2016
New rules in Super Mario Maker and why I don't like them
And one of the reason Super Mario Maker is so much fun is all the tricks and interactions between objects that you can find. Some of which have only been recently discovered. When you add a creative mind to these ideas, you can get some amazing levels.
Did you know that podoboos (The fire balls that normally bounce from lava) can pilot a Clown Car? And that this Fire-headed Clown Car can then be used to light up bombs?
Did you know that you can stand on a P-switch and use it to enter a door as long as you press UP quickly enough? Did you know that falling donut blocks can be jumped to and walked over, which is cool because thwomps can make them fall over?
Did you know that, by using tracks, you can make elements fall into the same track and thus share the same position. Which you can use to get fun results such as giant fireballs that shoot fire balls at Mario?
Did you know that, by using enemy stacking and podoboos you can place some objects with a half a grid square offset of where the game usually allows you to place them?
Those were various examples of cool interactions between the elements available in the game. Super Mario Maker is , after all, all about finding these interactions. The game encourages you to look for new things. It never tells you explicitly that dragging a super mushroom to an enemy can make it larger. Or that dragging a fire flower to a mushroom can make it a tiered powerup. You can attach canons to enemies, but the game never tells you this explicitly. It waits for you to find out on your own, through experimenting with the editor or by seeing it in someone else's level.
This is what the game is all about. Exploration. It wants you to try new things. New combinations. Behaviors that might not be obvious at first but the result of combining multiple elements in ways that maybe weren't explicitly intended by Nintendo. Goombas stacked on one another while on top of a treadmill and close to a horizontal spring look like they are dancing. Bullet bills can trigger P switches. Make fire sticks share the same position to make new shapes.
The course included content that the Super Mario Maker team judged to be a bug in the game.
Then we have a problem. Because the inclusion of a bug in a course may have been the result of this very exploration. In fact, some of the things I mentioned might be bugs. This is 100% dependent on what Nintendo decide to call bugs and since the rule is ambiguous and punishes ALL usages of bugs and not just the ones that have the intention of ruining the players' experience.
It's not without precedent. In the past, there was once a trick that allowed you to place two objects in the same square in a way that the player sees one object but it in fact behaves like another one. This trick used a process similar the podoboo trick above, relying on placing objects on tracks and then removing the tracks in a careful way. Some of the most interesting Super Mario Maker levels I've played showcased this trick. We had clouds that became blocks, solid blocks that disappeared when a P-switch was pressed. Slippery blocks. This bug opened a plethora of possibilities and enabled some very fun levels to exist. Unfortunately, Nintendo not only fixed the glitch, but they deleted all levels that were detected to use it. Including levels that didn't seem to really use the trick - Maybe the trick was used accidentally and in a hidden area that's not visible during gameplay or maybe the algorithm to detect levels using the trick had false positives.
It's sad to think that the penalty for having bugs in your course has actually become worse. They will no longer just delete your level and make you unable to upload it again. In addition, they will wipe all your stars. All of them. Even those gained from 'legit' levels. The maker with most stars in Europe, Hyrulean, lost all the stars given to their account. Someone who used to hold over 500000 stars now has around 1000 stars. This is an extreme punishment for having a single glitch level out of 81 courses.
These rules need to be changed to specify that only harmful bugs will be subject to this punishment. There have been makers that intentionally make levels that crash the game and that's indeed behavior that needs some sort of measure. However, an ambiguous statement on anything that the dev team might think is a bug is a very harmful rule. It discourages the key elements of this game: Experimentation and Creativity. It also adds a level of discomfort to the craft of making levels, you don't know if Nintendo might suddenly decide that something in one of your levels is a bug and you might lose all the work you put into this game. Nintendo need to pursue making the game more enjoyable, not by limiting our creativity but by nourishing it.
Thursday, October 08, 2015
Super Mario Maker - The Bad
Hello everyone,
Have you heard of Super Mario Maker? It's a wonderful game by Nintendo that allows you to "create and share" your own Super Mario Levels.
I first heard of it in June when I found the Nintendo World Championship Finals video in youtube and I have been getting hyped for it since. By August I was really excited, just a couple more days and we should go buy a wii U and get Super Mario Maker.
On September the 1st, a car hit me and I temporarily lost right arm mobility. I was sad because of all the things I was going to miss out, including SMM. Except, that by the 10-th I was still hyped and realized that it was actually possible to still play Mario using the gamepad attachment in the Wii controllers. So all was setup and I still acquired it. To say that this game has made me endure the long wait for my bones to heal would be an understatement. I really think the distraction and the lack of frustration from missing out has been a massive help to my mental health during all of this and also I have the perfect reason not to stop using my right hand fingers during this.
The Game itself is top notch. Even though I watched so many videos that few things were really a surprise to me. I was ready to start making "the levels of my dreams" and the interface was not going to be an obstacle. Everything about creating levels in this game flows incredibly well. The strange touch screen Wii U 'controller' works extremely well and this game makes it seem like a good idea. It's really impressive.
I made some levels, I submitted them. I was also very interested in playing levels from others, so I played them. There was just a small problem...
... Nobody plays my levels
I don't think I am exaggerating. To this date, My oldest level, "Use the Shells" has been played by 45 different people. It's my second-most played level. My most played level has 61 plays.In the image, the number next to the foot icon represents the number of people who played it. The flag represents the number of times it has been passed (four!) and the number below it the total number of tries. Out of the 45 people who played, they in total played 290 times. This means on average each person invested 6.44 attempts to win my level. I've received 6 stars.
I created this level on Saturday 12-th, a day after the official release date. I was barely spamming objects on the course creator hoping to unlock new elements when it occurred me to make a semi-puzzle level using shells. There were some okay ideas in this but nothing outworldly, just situations in which you need to kick shells in order to break blocks. Tried to have a Mario flow in the level, making the complexity progressive and adding breaks in which you can get coins / gratuitously kill enemies outside of the puzzle setting.
This was not a good level. In fact, I corrected it and made a version with less frustrating aspects. I'm not complaining about the low success or star rate. But the low play count overall. Must mention that many other levels I made in which I spent more effort have even less people playing them. We are talking of a total of 45 people, since release weekend, in a game that sold millions of units. For comparison, the top starred level has more than 750000 next to the foot icon. What is going on?
Top Starred Courses
What does a player who want to play other people's levels do? The first suspect is the list of the top starred levels. The number of stars needed to be in this list is around the hundreds, and that's assuming the player will bother to scroll down and reach the bottom of the list.ars technica published an elaborate analysis of the levels you can find in this list. It's not really the type of levels that is concerning to me. I don't share the vocal dislike for autoplay levels. A far more worrying trend is that every author you can find in this list seems to have visibility as a youtuber, or is a big streamer in twitch or has been otherwise featured in a large channel. Don't get me wrong, most of the levels in this list are very nice levels (although a couple of youtubers are definitely overrated). The problem is that in order to reach this top list you need to be already famous.
One of the issues is that the list is stale. Even the option to consider only stars from last week doesn't seem to stop it. Once you play many of the levels in this list, you'll notice that it barely experiences any change. It would be nice to be able to downright hide any level older than a week. I would also love a "last day" option and perhaps even a "last hour" once. It seems that there's only a "last week" option because Nintendo didn't expect the enormous volume of courses that was uploaded.
Featured?
There's another section called featured. It's nowhere explained how this section works. Many players believe these levels were picked by Nintendo staffers. Watching this list closely doesn't seem to confirm this. For example, there's a [refresh] button that makes a completely new list to appear. If these were manual picks, you wouldn't expect them to go away as easily.It's possible that this list shows levels that are found via heuristic to be getting stars in an unusual radio. Some of the levels that appear in this list can be quite good, but there can also be some less good ones. The inconsistency hints towards an automatic kind of curation being involved.
The 100 Mario Challenge
For level makers that are not widely known and who aren't willing to put the work that is promoting their work. The 100 Mario Challenge is the only hope to have levels become known.The 100 Mario Challenge let's you pick three difficulties: Easy, Normal and Expert. It then provides 100 lives to beat 16 levels (8 in easy mode). If the player is successful, they rescue princess Peach and unlock a weird mushroom costume - These costumes allow Mario to look like another character, there's a wide variety of costumes to unlock including characters from other Nintendo franchises and even Sonic, Megaman, Pacman and Some Pokemon are available. If you instead lose all 100 lives, you get a game over screen. During the game and when the course is beaten, you can leave comments and stars if you like the level. If you don't like a level or think it's too difficult, you can skip it at the cost of one life. The whole process of finding worthy levels without external aid is centered around this challenge.
The problem is that the challenge is motivation for players to beat 16 levels. But it doesn't matter which one. There's no reward for persistence, in fact, it's punished. Players who skip levels aggressively whenever there's too much risk in the level will lose lives at a smaller rate and have more chances to unlock the costumes. Nothing encourages the player to star / comment the levels they liked. In addition, there are levels out there that are made in bad faith: Levels that are unbearably difficult unless you are the author and know the secret shortcut to the end. These shortcuts can be very elaborate and obscure or rely on bugs in the game, making the levels effectively impossible for anyone who is not the author. After facing such things and also the frequent low quality levels, players of 100 Mario challenge would run out of patience and be more prone to skip.
If your level has failed to call the interest of the player and has made them lose a couple of lives already, it might be skipped. This will ensure the success rate stays low, 0% or close to 0%. In turn this will make the level be classified as Expert. In Expert mode, the problems are amplified. Not only are players less willing to spend lives in your level, there are also far less players playing in Expert mode. Once my levels reach this state, I can easily tell because the rate at which players play the level drops noticeably.
Following Makers
The game also provides an option to follow your favorite makers. Unfortunately, a more suitable name for this feature would be 'bookmark'. You can have a list of makers you like and manually open their pages to see their levels. It would be far more useful if it generated a feed with the latest levels by people you follow (and perhaps also levels starred by them). In its current state this feature is useful only to save you the hassle of constantly typing your friends' level ids.Up and Coming
"Up and Coming" is the section that shows levels as they are uploaded. Few people seem to like the idea of trying these levels. This section is useful to see one of the root issues: One thing you can tell is that hitting the refresh button makes a bunch of newer levels appear. It seems like a couple of minutes sees the upload of a few tens of levels if not hundreds. There's just too many levels. We are talking far more than a single person can play in their whole life."You may also like"
One last method the game provides for discovery consists of a list of courses you may like to try just after playing another one. The results seem to be also based on stars and similarity to the course you just played. The suggestions tend to always have an already large amount of stars.What does it matter what others think about your level?
Why not just enjoy making levels and sharing them with friends? Unfortunately, SMM is presented as a game and like even the most closed-minded definition of a game, it has failure conditions. There's a limit on the number of levels that you can share, the only way to raise this limit is earning stars. If you wish to share levels with your friends you will need to keep the limit in mind.Worse still, The Manual implies that levels that don't reach an undisclosed amount of stars will eventually be deleted.
I wish you could share levels in private , outside of the limits and without the level getting picked for 100 Mario challenge. Until then earning stars is really a mandatory part of the game if you are the kind of person to want to make a plenty of new things.
Third Party Sites
In the realization that the game's methods for course discovery won't help you when your level has barely any plays and less than 10 (or 3) stars, you might try to advertise your level in third party sites. That's the moment you realize that everyone is having exactly the same problem.Try any article in a major site discusing Mario Maker without asking for level ids. There will be people posting level ids in the comments. E.g these replies to the Kotaku article by Patricia Hernandez about how to find good levels:
The worst part of it is that it doesn't work. Very few people will actually try random level ids they find.
Try a twitter search for #SuperMarioMaker and #MarioMaker HTs. Ignoring the large accounts and the videos, you will find find plenty of ids, in tweets that seem to have no RTs or Favorites or interactions whatsoever.
Nintendo Life has a section where users can submit levels. There are currently over 7000 submissions, but the top rated level has ... 27 likes.
The /r/MarioMaker subreddit has a daily level exchange thread. You are encouraged to play 4 levels before posting your own level id. If people followed these rules, posting your level would be almost guarantee that 4 people will play it. In practice, you are lucky if one person plays it. I've had mixed luck with this but many times I play 4 levels (and the levels tend to be very good) and comment and give feedback but have my level ignored or played by a single person that gives no feedback.
You may try going to twitch and find the rare streamers who don't do 100 Mario Challenge or stream their own level making. A handful of streamers may accept requests to play specific ids. These streamers eventually find their queues collapsed of id requests and decide to stop accepting them.
There's an intrinsic problem in trying to use third party sites to promote your levels. Those sites are already full of other people trying exactly the same. Meanwhile, the players seem to prefer to stick to the (poor) tools the game provides. This might be the reason players find themselves complaining about the terrible quality of Mario Maker levels. Like this now infamous post in the Washington post: “Super Mario Maker” is an engine for circulating horrible new “Mario” levels
To Sum Up
Nobody plays my Mario Maker levels and there are plenty of level creators finding themselves in the same situation. Meanwhile, players willing to play nice levels have to settle with a very poor curation system that mostly benefits people with large fames prior to the existence of the game. SMM is one of the first serious attempts from Nintendo to rely on player content and it shows. Something must be done about this.Meanwhile, I'll keep spending hours developing and updating levels that will be played for a minute before skipped in Mario Challenge. I have way too much fun doing this and will dedicate this blog to talk about my attempts. I plan to include serious opinions like this post and also Level/Game Design talk. I have no control in regards to how many people play my levels, but I can put my best effort to make the few ones who do stay engaged and not frustrated.
I really, really want to talk about my levels. Welcome to this Mario Maker blog.
Saturday, February 08, 2014
vexorian FAQ
I keep getting some questions so I am gonna leave answers here.
Q: What tool do you use to draw your images?
Whenever I have no idea how to explain a problem, I use images in the editorial / problem statement. My images tend to look pretty darn good. So it is not uncommon I get this question. The short answer is : I use inkscape.
The long answer is, that as you might figure out, inkscape is actually just a simple vector graphics software that is not even a full tool like Adobe illustrator. I use Inkscape because it is free and cross platform. Cross platform is important because I use Linux. Free is important because I avoid promoting proprietary software and a very effective way to avoid promoting proprietary SW is not to use it. I am not a graphical designer, so I can easily afford using Inkscape instead of a costly tool with ethically dubious licenses.
But I think the question is really: How do I make images look so good in editorials. Well, first of all, I have had plenty of Inkscape practice before becoming an editorial writer. I had to learn a ton of Inkscape when I was making graphics for a game that is called Xye, eventually, I made my brother the graphics designer make a new, more advanced skin, but I still like the graphics I was able to make... Of course, when I started writing editorials, my inkscape skills weren't so good either. I still needed to have more and more practice. I am far of being an inkscape expert, but I did end up making quite a large number of images that explain algorithms. So there is that.
The other part of the equation besides practice is that I make sure that the images are rendered as vector graphics instead of bitmaps. This makes the images look good regardless of scale. My editorials have plenty of javascript and CSS tweaks that make the images use SVG format and scale them up or down depending on the user's resolution. Albeit, it is a bit pointless at the moment because TopCoder's wiki site does not have a mobile mode :/ But if your PC uses very large resolution, you might notice something :)
Q: Do you even have a job?
(Or variations like "where do you work?", "Do you work for Google"* , "Do you study?" )
I have a job, I am the editorial writer at TopCoder.com !. Really, that and the occasional SRM problem set is all I am doing for a living right now. It is not the most profitable job ever. And I am only an "independent contractor" of TC, meaning I have no fixed salary, benefits, protections or responsibilities (besides delivering "deliverables" in a decent time) In fact, it is getting extremely time-consuming lately with SRMs getting a lot harder and more frequent than they used to be. But it is okay to me, and it fixes my needs. It allows me to earn money by programming in mostly c++, programming cool little problems as opposed to software (I HATE software development).
I also supposedly study. In my case University was a terrible, terrible thing that didn't work out very well. I am extremely late in graduating. I don't even care anymore, to be honest.
* Actual question happened at least 6 times, for some reason.
Q: Why don't you have a red rating in topcoder?
I am just not that good during contests. I actually constantly struggle to solve the division 1 hards and mediums before being able to explain them. Specially lately, every tutorial has been a little miracle. In this very moment I am facing issues solving a division 1 EASY problem!
Q: Why don't you participate in Codeforces / Codechef / ACM / etc
- I try to participate in Codeforces. I don't love it that much but I sort of like codeforces. The contests are more challenging (because Codeforces' division 1 has higher density of uber good coders than TopCoder's division 1 has). Although the probability to find problems that are repetitive or annoying is also slightly larger. The main reason I don't join more Codeforces contests is time availability. Specially with TC editorials taking a lot of my time. When I am not writing editorials I am a bit tired to be participating in more contests :/. Also, about 1/2 of the time, the time slot is quite incompatible with me. Sunday matches, for example, are very hard for me to do.
- Codechef has similar issues. It is in third place so it has much less priority than Codeforces - If I only had time available for one contest and I had to choose between Codeforces and Codechef, I would choose Codechef - so it is less likely I'll participate. And the times Codechef picks ARE TERRIBLE FOR ME! Like I mentioned, Sundays are a big no for me, so that means no Cook-Offs. Solving the 15-day monthly challenge sounds like a Herculean task considering I possibly already spend 15 days a month writing editorials :/. I am also not a big fan of them using ACM rules for cook-offs (see below).
- ACM / ICPC / their online judges. Did I ever mention I hate the ACM contests? They have these terrible format/scoring rules where problems letters are randomly-assigned. The time you take in the first problem is weighted excessively in the final rank; Groups are mandatory; The problems are low quality (They have been improving a bit , but not enough); etc... :/
- Hackercup: I would need to join facebook to participate in this one. And that's not going to happen.
Q: How do you solve $HOMEWORK_PROBLEM?
I am not a forum, I barely have time to solve problems that I get paid to explain. Could you avoid contacting me personally to solve a specific problem? Unless it is a problem I wrote and no one has submitted a correct solution in the practice room / spoj... Well, I am not saying that you should *never* send these problems, but don't expect me to be very helpful. Many times I do try to solve whatever problem people sent me, but remember: I am not that good at solving problems! Many times I have no idea how to solve the random problems you send me :/
Thursday, December 26, 2013
Just saying...
If you don't like the idea of TopCoder getting a generic logo and renaming the Algorithm and Marathon competition tracks into "Data". You might like to join this discussion
Monday, December 16, 2013
SRM 600 prelim editorial and recap-rant
So the double contest trouble last weekend ended and it was disastrous to me. But first , let me point you to the first 5/6 of the editorial at : http://apps.topcoder.com/wiki/display/tc/SRM+600
There were t-shirt prizes and I foolishly hoped to maybe get a t-shirt. I forgot how bad SRM 500 was on my luck.
Div1 250
I solved this one right-away. You need to pick the bit position that is non-zero in goal and that has the least valid cards. I needed some time to code it and then the strange self-doubt about "maybe something is wrong", also I really wanted to make sure to get that t-shirt. I reviewed the algorithm plenty of times and proved it to myself. So I submitted it. It wasn't a slow submission, but it wasn't particularly fast either, so I rushed to solve div1 600.
It was some time after the system tests that I learned my solution actually got challenged. I was very skeptical, because I was sure the algorithm is right. Well, the algorithm was right, but for some reason I initialized my result variable with 40. I am not sure exactly what happened. It could be I made a typo and typed 40 instead of 50. Or it could be I got the constraints confused and thought to type the maximum number of bits. I don't really remember.
There is a fun story about this challenge that ruined my dreams and rating. I already wrote about it, so here is a link.
Div1 600
Palindrome matrixI thought that my only hope for t-shirt was solving this problem. And for plenty of time in the match I thought I could do it. My first solution was actually quite close to correct. The only mistake I made was not to figure that you only need sets of palindrome rows/columns with exactly the required number of palindromes. You are not really going to care about the rows/columns so it doesn't really matter. You can actually read the first solution I tried, it is in the site statistics, it was `O(3^m)` because reasons.
When I finished coding it, I had two issues: a) It wasn't giving the right answers to example cases. b) It was taking too long (~4 more seconds than allowed) to solve the large example case. I made the mistake of thinking [Even if I fix this, it would be too slow]. It turns out that besides of bug fixes, the soution was correct. It just needed some pruning and to care only about sets with exactly the required number of palindromes. The new code was a dynamic programming that in reality did exactly the same as the old solution, I just didn't notice... New code was also wrong and somehow still slow. So the coding phase was a missed opportunity.
Anyway, this was a cool little evil implementation problem. I wish I solved it during the match.
T-shirts
It annoyed me that division 2 coders were getting t-shirts. It is a way to punish blue and yellow coders for not having low rating. I think that in matches with awards it would be preferable to have a single division (combined div1 and div2).
SRM 600.5
I wish this match didn't happen. So there was a new chance to get a t-shirt. But this time solving very hard problems. The match was advertised to have a normal SRM 1000 points problem. So I went to the match thinking of spending 4 hours on that problem and hopefully solving it. It was actually very obvious that far less than 40 coders were going to solve more than one problem in this match. When I learned the match actually had a challenge phase, I felt robbed. It was obvious that people were going to submit bogus solutions for some reason, allowing other people to get 50 points and probably joining the top 40.
Really, the TopCoder format is terrible for this kind of match. If the act of opening problems didn't penalize you, it would have been much better to open all problems before deciding which to solve. Instead, I had to rely on the point values assigned to the problems, which were terribly wrong. The 1000 points problem I spent 4 hours trying to solve was solved by no one.
It was a interesting problem. Come up with `n` distinct positive integers such that, for each `1 <= i <= n` , the sum of the `i` largest integers is less than or equal to `s_(i-1)`. Where `s_i <= 1000000000`. I spent a whole afternoon trying to find a secret. Trying to decode the safe that hides the solution to this problem. All with no luck.
So the t-shirts given to people that just got lucky (Many rooms didn't even have any submission at all, whilst some rooms were full of bogus solutions). It was a bit of a waste of t-shirts. I wish they would have included at least a div1 medium or easy problem so that there was a better tie-breaker than the challenge phase. IMHO, maybe not include a challenge phase at all.
Comments?
Problems seemed good. I am just in a very bad performance streak. My decisions during contests are seeming to be very bad lately. Also, I seem to have completely lost the ability to correctly estimate whether a solution will run in time or not.
The way the SRM 600 celebration was made was very disappointing, giving prizes to div2 in SRM 600 or to people being very lucky in SRM 600.5. I would have preferred to have a single division in SRM 600 so that if div2 coders win a t-shirt it is by performing very well , or by being lucky. SRM 600.5 really didn't need a challenge phase...
Monday, December 09, 2013
SRM 599 Recap and editorial : Cursed
I just barely finished SRM 599's editorial. After failing this match both as contestant and editorial writer. My conclusion is that this match has been cursed.
Div1 250
(Read editorial for actual explanation)
I was so happy with this problem when I first read it and... horribly misinterpreted it. For some stupid reason, I thought that when doing the second kind of step, you would always raise the number to square. I am not sure why this assumption happened, or how I managed to misread the problem. But it happened. The reason I liked this, is that with this assumption, the problem reduces to a div1 250 we already solved very recently. So I thought that sort of thing was cool.
I coded my solution, it passed example tests (should so confused solutions pass example tests? Maybe examples were weak?), moved on to div1 500.
Challenge phase and destruction
For a second I thought of not participating in the challenge phase. I was sort of busy that day. But last minute I decided [[It is likely people are making all sorts of bugs in 250 and bad assumptions in 500]]. I was right. Unfortunately, the first solution I opened was correct, but I didn't know it was correct (remember I misunderstood the problem entirely). So I challenge it. The challenge failed and the [Correct answer] provided by the system didn't make any sense to me. That's when I figured that a) My 250 was utterly wrong. b) I had a bad challenge, so this means -25 overall points. Worst position possible, worst rating loss possible. My only hope was to find codes that were wrong and challenge them and recover frm the -25. And to do it fast, because if someone challenged by 250, I would not be able to make any challenges any more. I tried a solution, my challenge was also wrong. Gave up...
Div1 500
What a hellish problem from hell!
During the match, I was able to do just about most of the theory. You can only use integer sides. It is impossible for odd cases. Even cases can be solved with 4 sides. You need bruteforce to find out if a triangle is possible. Unfortunately the time I had allocated during the match was not nearly enough for me to code a solution using this idea and optimize it. OMG, optimizing this brute force was so difficult.
I think this problem would have been a good div1 medium, if it only had the theory part. Such complex implementation on top of the theory makes it too extreme for this slot, imho. The constraints were certainly too tight. I think L <= 1000 or 2000 would have been just fine.
I had so many issues solving and explaining this problem. I had to spend ages coming up not only for optimizations, but for optimizations that I can prove are correct. Eventually it was clear I was not going to finish in less than 48 hours if I wanted to solve this problem. So I moved to the hard... Bad idea.
Div1 950
I didn't open this problem during the match. At first the description sounded very easy. rng_58 called it "an implementation problem". Well yes, but not that much. I didn't really understand how the recurrence worked, and I had to do plenty of reverse engineering of rng_58's code. ... If only Petr made his blog linking to author explaining it in codeforces before, maybe it would have been better. ... (BTW, why?, why can't we have TC problem set writers explaining that way in TC's forums? I mean, how did TopCoder manage to kill its community so much? The forums used to be so active and interesting before)
Finishing the editorial
When I noticed, I was already late for both deadlines. And I was finally understanding how to do the hard. Then I had to fix again what I had for div1 medium. Then do the other problems, which were not non-trivial to explain at all. There was a time period in which I thought I would never finish this editorial.
If you think editorial delays are bad for you, editorial reader, think about how awful they are for the editorial writer. Instead of spending a couple of days in a SRM, I ended up spending almost a week on it. There's plentyof things I couldn't do because of it.
Comments and please vote
Any comments. Also please post feedback to the editorial page, specially, vote. I really dislike that there are so few votes (negative or positive) in editorials when SRMs have hundreds of participants. (Did I already mention something about TopCoder's community being dead?)
The problem set was cool, although 500 was probably too interesting for div1 medium. Maybe swapping div1 500 and div1 hard and making div1 hard have smaller constraints would have been better? I really dislike to have failed this match, I really could have done more.
Wednesday, November 20, 2013
SRM 597: argh
The other day I accepted to write editorials to the TCO. Unfortunately they never warned me that some of the problems I would read could end up getting used outside of the TCO. I only learned that after the problems were sent to me. Had I know that I could miss SRMs just for helping with these editorials, it would have been a deal breaker. I hate missing SRMs. I really hate missing SRMs.
I had hopes that maybe if one of the problems I read gets used like this in a SRM, I could at least have a chance to write the other problems in the SRM. Nope. Then I tried to maybe get added as a tester to read the other problems so I could at least have progress in the editorial. Nope. So missing this SRM was useless. Week ruined.
Div1 600: ConvexPolygonGame
This is the problem that ruined my week. Two players take turns. It all starts with a convex polygon. In each turn, the player draws a polygon such that:
- The previous polygon contains all the vertices of the new polygon.
- The vertices of the new polygon are lattice points
- No three vertices are colinear.
The player loses when it is impossible to draw such a polygon.
The trick is to notice that as long as a player can make a move, the player can always pick a minimal triangle that will win the game. We know that the game will end with a single triangle. Imagine this triangle came after a sequence of moves. This triangle will then be inside each of the polygons used in the game, including the first one. Then first player can just directly use this triangle and win.
So we just need to check: Is there at least one triangle with non-zero that can be drawn in the first turn? If so, first player draws a terminal one and wins, else the first player loses.
So far it is a cool little problem. The original version planned for TCO had `(-500 <= x,y <= 500)` constraint for the vertices of the first polygon. Which had a couple of cute solutions, for example, you could iterate through all the points inside the polygon and if you ever find a point that is not colinear to the previous two points, the job is done. Unfortunately, when migrating it to SRM format, they changed the problem by making the constraints much larger. So the clever conclusion that you only need to check if one drawable polygon exists becomes just problem obfuscation, because the real issue is to work up the implementation problem of checking for that condition. Apparently the idea is to use only the points that are close to the vertices, within 200000 distance or something like that.
I think this problem was a decent TCO finals easy with the small constraints. With the large constraints though, it becomes a SRM div1 medium with excessive implementation that doesn't make it more interesting.
Friday, October 04, 2013
More answers to Quora questions.
Weeks ago I wrote a post: vexorian answers quora questions. It was a fun blog post to wire it, so I am going to answer some more:
What are the things you wish you knew when you started programming for the first time?
In general:
- Speed sucks. There will be some situations in which speed matters, and it is good to have a language that is not like super ultra slow. But unless you have very specialized applications, low level speed should never be your primary objective. (high level optimization is cool though)
- You'll spend more time reading your code than typing it. So make it readable for god's sake.
For "Competitive programming" :
- There is no money in participating in contests. There is good money in working behind the scenes though.
- You did not solve a problem until you code a passing solution. No, you didn't. No, just knowing what the solution is is not the same as solving the problem.
- It is pointless to spend weeks trying to come up with solutions on your own. If you can't solve a (practice) problem after some hours, search for the solution.
- Similarly, it is pointless to look for answers immediately after reading a problem's statement. Always give yourself a chance to at least try solving it.
- You need a plugin to code in TopCoder. Really, you do.
(topcoder) Do you use the Coding Area to code your solution or a separate IDE?
IDEs are the spawn of Satan, but the arena is very limited. You need a plugin. Until recently I've been using a modded KawigiEdit. Lately I am using Greed. I use jEdit to edit code. Each programmer needs a specific set of editor features and in my case I prefer to have fewer features as big editors "get in the way".
How should I practice so that I will be at a level where I can approach TopCoder's Div1-500 problems with confidence?
Sink or swim. What I did when I noticed I was getting stuck in division 1 easy difficulty was to open the div 1 500 first. This way I was forced to solve a div1 medium every once in a while or else my rating would be destroyed. Plus I eventually got used to at least being able to try this slot. I know that this doesn't help your issue about [confidence], because you'll need to at least once try to solve a div1 500 during a match knowing that you don't have a confidence to solve them. But you don't really need the confidence.
Difficulty is not static though, with time problems became tougher and I have had to repeat the effort more than once.
Is it better to learn algorithms from a book or by solving online problems?
I've been meaning to say something about the Books topic in this blog for a while now. Books have not really helped me that much. Whenever people ask me about books, I bring the two closest things to a book that helped me, like Programming Challenger and CLRS. But the other day I learned that I don't even know the author's name for Programming Challenger.
In my case, I think that reading online resources (Editorials, tutorials, howtos, wikipedia pages, etc) and asking questions in forums was far, far more useful than books. Any good contest site should have a resource like that. Try to solve a problem, then after the contest, ask how to solve it, read editorials and any material suggested by people explaining the problem. But if you like getting theory from books, feel free to do it.
Why do a lot of successful competitive programmers not participate actively on CodeChef but participate often on sites like TopCoder and Codeforces?
I don't know about successful coders, but I can speak for myself.
- I don't have time to participate in all contests released in a month, so I have to put priorities.
- I choose TopCoder as my first priority, because the 75 minutes format is a lot more comfortable than longer format, and because I would likely have to solve those problems anyway because of my job.
- Second priority is Codeforces because it is has a very competitive userbase. Although it sort of bores me some times.
- Why Codeforces and not Codechef? The Codechef format is not helpful. Spending 15 days on a contest would really kill me and leave me with no time for other things. The cook-offs sound ok, but they happen only once a month, and on Sundays, and at a very bad time of the day for me.
How should programmers place their hands on the keyboard in order to increase the typing speed
Uh? Unless you have serious difficulty typing at a decent pace, you shouldn't care that much about your typing speed. Other factors are more important, like thinking of the algorithm you need to code.
If you do lack typing skill (For example, you need to see the keyboard while you are typing), then there are good resources to learn typing out there in the web and practice makes best. typeracer offers both a place where you can practice typing competitively and the forum is a good entry point to the part of the internet that cares about typing speed and has tips/etc.
I learned to type in school around 18 years ago. They made do typing in typewriters, if you got something wrong, you had to restart over. Yeah.
Do you find skills you achieved during programming contests to be useful outside of them?
I personally wouldn't have learned C++ nearly as well as I had without programming contests. Programming contests give you a very good opportunity not just to code solutions to known problems. but to make mistakes when coding those solutions. Because the problems are well-defined, we can run your solutions against a fixed-tester and find a plethora of implementation bugs. Constantly. This will teach you about what things can fail, what pitfalls your language has. What sort of mistakes you are likely to make.
Rant: My god, look at the answers to this question. Read this: Regarding the smug opposition to programming contests. Specially the anonymous guy who thinks adding a competitive layer to programming is to "prostitute" programming.
Programming contests are fun and that should be your first priority. There are, however, some nice skills you can learn through them. It is true that they are skills you can learn in other ways like making contributions to open source software, the demoscene, modding, making your own apps, building robots, etc*. To each their own, if you have more fun at competitive programming than in those areas, then programming contests are a good way for you to develop these skills. The trick to programming is to pick an area you are passionate about and develop your skills there. It is incredibly stupid to be afraid to pick areas of programming that do not have the approval from random people in question sites...
(*But of course not college! lol!. I am talking about skills that require creative coding ability, things college cannot really teach (sorry!) ) Speaking of college, while a good college should be better at teaching you CS theory, the programming contest world is probably a better place to learn CS theory than 99% of colleges.
What do you do when your code is not accepted but you don't find a test case that makes it fail?
If you can't really find any test case, then you are wasting your time solving problems in a judge site that doesn't share test cases. That is very bad for your productivity. Avoid those sites like the plague they are. While there are urban myths about how making you find the wrong test case by yourself will make you better at programming, you should consider that transparency is very importance. Have you stopped to think, what if? What if your code is actually correct? What if the judge was wrong? What if that's the reason you can't find a wrong test case? Transparency = guarantees. If somebody thinks he will get better by guessing the test case he is failing, he can just not take a look at the test cases.
If your problem is different and you actually know that your code is failing a case, but it is a very complicated one so it doesn't tell you much. Then you'll need to get creative.
- First of all, why is it that apparently none of the simple test cases was wrong? Maybe your code has issues that are specific to large test cases? E.g: A memory write out of bounds of an array could be corrupting your memory. E.g.2: Overflow.
- In topcoder, sometimes some large cases of the system tests are first in order to other, simpler cases. But since system tests finish running once they find a wrong test case, you cannot find out the simpler cases. What I do sometimes is manually pre-code the results to each complex case until I find a simple case that executes after them and is also wrong.
- Read editorial / tutorial and try solving with the solution described in there . If the solution in the editorial is the same as yours then you probably need to inspect each line for possible errors. That is sometimes all I can do, verify each line, sometimes multiple times. Sometimes I fall sleep while doing it.
- Ask in the forums. But please, help us help you. You need to explain your solution and why do you think it should be correct. If you don't have a proof that your solution should work, then it probably won't work. Probably its bugs are not small implementation mistakes but the whole algorithm is wrong. Sometimes it is better to just redo the work. If you have been having issues proving a solution is correct, then maybe you should try to prove it is wrong. Unfortunately this involves finding counter-examples and that's exactly what you are looking for.
- If everything fails: Grab somebody else's correct code and generate random, small, test cases until you find one that makes your solution give a wrong solution. Maybe you will finally find something.
- If that fails, give up.
Why is Python not allowed as one of the languages for ICPC?
I'd say some tournaments just can't keep up :/
How can I print 1 to 100 in C++ without a loop, GOTO or recursion?
Lambda power (requires c++11):
#include<functional> #include<iostream> using namespace std; int x = 0; void q() { if (x != 100) { cout << (++x) << endl; } } // t(q()) returns a function that calls q() two times. // t(t(q())) returns a function that calls t(q()) two times == q() four times // ... function<void()> t( function<void()> g) { return [&g] { g();g(); }; } int main() { // call q() 128 times: t(t(t(t(t(t(t(q)))))))(); return 0; }
Laziness power:
#include <iostream> using namespace std; int main() { cout << "Please type all numbers from 1 to 100 in a single line:"<<endl; string x; getline(cin, x); cout << x; //If user does his/her job correctly, this statement will print the numbers return 0; }
Monday, September 30, 2013
SRM 592 Editorial and comments about the match
The editorial is up: http://apps.topcoder.com/wiki/display/tc/SRM+592 and I have some things to say.
The delay
Lately I have been trying really, really hard, to get editorials ready within 48 hours after their match. This time I had to break my successful streak though :(. You see, When the match ended, I wrote my recap , then I caught a tweet from rng_58:
1000 は Slow Fourier Transform です
— rng_2 (@rng_58) September 27, 2013
Yep, even though it is in Japanese, it was pretty clear what was going to soon happen to me, as the editorial writer. I have never gotten the chance to learn FFT correctly. Although I tried to figure the theory out, it is a bit confusing. It did take me around a month to actually understand max flow.
Yesterday, I was already past the 48 hours deadline and I really didn't want to, once again, have an editorial take one week of my life, plus I really hate the delays. When an editorial is published too late after a match, most people are no longer interested in the match...
Lately I've been learning that it is sometimes better to admit limitations and delegate. It's not the end of the world if I don't write all the explanations, and knowing my limitations is good. If I really did the thing in which I spend a week working on this editorial, then I would have to delay the next editorial too because of being tired. So I asked Rustyoldman to write this explanation and split the payments. Yay
What is up with division 2 problem sets lately?
I am not sure what's going on, but it seems to me that division 2 problem sets are getting harder. This match's div2 easy requires a proof and the div2 1000 was incredibly complicated, imho. It is an "easy" dynamic programming problem in which you can easily see that it reduces to dynamic programming. But the time and memory optimizations took me a serious while to get to work correctly. This is the second div2 hard in a row that feels out of place and, to me, closer to div1 medium.
The nice evilness in div1 medium
I mentioned in the recap that I tried to come up with a way to split this problem in sub-problems during the match. Well, that was not all the story. The first thing I did when trying to solve this problem during the match was to reduce it to generating a single permutation instead of a pair of permutations (this is the trick to solve the division 2 version quickly). During all the match I was trying to solve this modified version of the problem, and it seemed very complicated to find a polynomial time algorithm.
Then I read ffao's explanation in the forums. It suddenly felt too easy. As long as you don't make the reduction to a single permutation, it is actually easier to come up with a polynomial time algorithm. This is quite a special problem and something to keep in mind. It appears that changing the problem to generating a single permutation instead of two would simplify it, but that't not always true. There is a reason why reducing a problem A to a problem B is said to mean that problem A is as easy or easier than problem B and not vice versa. It is possible that the original problem A is actually easier than the reduction.
The match
I have no complaints about division 1, I actually loved it. The easy problem was fairly easy, but not in anyway uninteresting. Medium was cool, as I mentioned. The hard problem seems to have been enjoyed by the likes of Petr.
I would have done Division 2 much differently though. I think division 1 easy was a good problem for division 2 medium. Like I mentioned before, it is a good thing to share problems between the divisions. And next_permutation problems are not as interesting as the ad hoc div1 easy, plus apparently they give python coders a big disadvantage. Div2 easy may have been slightly harder than usual. But specially I would have given div2 hard smaller constraints. Much smaller , actually.
Saturday, September 14, 2013
vexorian answers quora questions
So, there are a couple of fun things about quora, one is that it keeps plaguing my search results. The other is that when I tried participating in it, I got banned because it wouldn't allow me to use a nick name. Seriously, I am my nick name. I stopped being my real name a long time ago. Anyway, I've found some questions that I cannot help but to answer. There we go, in no particular order:
Why don't more women participate in programming contests?
Computer science is already male-dominated, but programming contests are even more so (e.g. I counted only a handful of female contests at the 2013 ICPC). Why?
This question is asked on many fields and it is always the wrong way to approach the problem.
- What you asked: Why don't more women participate in X
- What you intended to ask: Why is X male-dominated?
- What you should ask: What is X doing (or failing to do) that drives interested women away?
Once approached from the right perspective, it is a very good question. And I have asked it myself too. My theory: Programming is sadly male-dominated in the first place. The reasons for that are varied and tend to have a lot to do with the bro culture. Programming contests are a super-ultra-niche of programming , and thus it has reduced participation to begin with. If you take a small percentage of programmers, it is more likely the first bunch will be 100% male. And when a group is already male-dominated it becomes very hard to change it. Because there is already an outstanding male majority, there are no guarantees that this world is going to be safe and comfortable for non-males.
How to change it? Well, I don't know. But maybe if the gender problem is solved in programming as a whole, then competitive programming will improve its chances too. Check out the Ada initiative. Although the Ada initiative makes me notice, maybe we need codes of conduct in on site competitions?
Let me clarify: Any answer that involves stories about how men are different to women. How men are supposedly more competitive and thus more likely to enjoy competitive programming is utter BS. The only known difference between male and female brain is that males tend to have bigger brains, and this has not been provenly linked to any difference in behavior, capacity, or skills.
What it is like to meet or know Petr Mitrichev?
So, last year I went to the TopCoder Open. It was a very confusing experience. Also, I really had no idea what to blog during it. I was supposed to blog during it to justify they paying my travel expenses. But that was the point in which I noticed I am terrible at programming competitions, or rather terrible in Programming Finals. The problems that those guys were solving were all very difficult and I had no idea where to approach them.
I did my best to improvise whatever blog post I could. So I took my netbook and went to some of the couches in the TopCoder Open arena (A place similar to paradise, because it had all sorts of free snacks and soda). While I was typing in the TCO wordpress thingy. I noticed the guy next to me was writing in blogspot. Then I noticed he was writing in Petr's blog. A seconds later, I noticed he was Petr. Which was strange, because from pictures I didn't recognize him at all. At that point I really had no idea what to do. So I pretended like it was not happening. I already had enough trouble trying to fake a blog post. The whole thing was so embarrassing that I never tried to introduce myself.
So my answer is: Maybe you already met Petr. Maybe we all did. Maybe he wanders all over the world and shares sits with random people/coders.
Does having a very low TopCoder rating make someone unemployable?
Nah. I think that if you are someone active in TopCoder then you are already in the top 10% in traditional algorithm skills. (Note that it is a one way conditional, many people in the 10% , specially women, don't participate in TopCoder.
But of course, you can have a high rating and be unemployable. You can have a mediocre rating, like mine and be unemployable. You can also have green topcoder rating, like Mark Zuckerberg and be an evil CEO.
How do programming contest problem setters make test cases ?
In various ways. I just make a python script that takes various parameters (constraints for the input) and then generates a random one. Some problems need some sophisticated generation algorithms that are by itself an interesting algorithm problem (or more interesting?). Then I run the program and generate 5s, 10s or 20s of tests following a spec. Change the spec to cover another area of tests, generate other 10s of tests.
It is also needed to make some manual cases. That probably needs you to know what (wrong) solutions to expect from coders. Each problem is a different story.
What are the good ways to switch between C++ and Java in programming contests?
Don't. You will hardly have many opportunities to use c++ in your life. Java on the other hand, will most likely be forced on you eventually.
Do red coders and targets read the full question in a SRM?
No, they read the first two lines and then guess the rest of the statement*.
* Seriously, high level coders are not superhuman, they need to read the statement just like anybody else.
Which format of online programming contest i should participate more if eventually i want to get placed at companies like GOOGLE and FB?(long or short)
Why would people limit their career future to two companies? But if that was my life objective, I would actually dedicate myself to make commits, tons of commits to open source projects. Get involved in Summer of Code and stuff. Programming contests are a messy gate for these things in my opinion.
Why do most people on TopCoder use C++ as their default language?
Same question can be extrapolated to just about all contests for traditional algorithms.
People will bring excuses like familiarity, or how few sites support other languages. Etc.
But what if c++ is just the best language for this? It is fast, the STL seems to have been designed specifically for algorithm contests, things that are usually a c++ weakness (like threading support) are usually not allowed in programming contests anyway, etc.
Is PHP a good language to solve problems of spoj,codechef and topcoder?
PHP is never a good language.
Is it disadvantageous to use python on TopCoder over other languages?
Hmnn, I answered this in a long blog post. Short answer: Against c++, it is a mixed bag, the expressive power is great, but the performance cost really bytes. Against other languages, it is better :)
How do I go from blue to yellow on Top coder?
Solve the division 1 easy problem in 95% of the matches you participate in. Do not challenge any solution. Even if it is totally wrong.
It takes me hours to completely understand solutions to 1000-pt problems on TopCoder. Should I get discouraged?
You are obviously talking about div1 hard problems. If so, don't worry. Here is a little problem setter secret: The only reason we add div1 hard problems is so that the very, very, very high level coders don't get bored. For 99% of the coders, they don't cause any difference in the competition. I wouldn't even bother opening them if I didn't get paid to write editorials.
By doing practice can one be a red/yellow coder inspite of not being that intelligent?
Over the years I have learned a key insight: Nobody is that intelligent. Intrinsic skills are really worthless. Hard work is more important. People like Petr started solving Math puzzles at age 11 and have not stopped since. It has nothing to do with intrinsic intelligence.
The whole tale of there being programming geniuses does not seem to agree with reality. And it is also a dangerous tale. The idea of intrinsic intelligence is not founded in science and tends to support awful ideas like eugenics. My tip is don't fall for this. It is a useless belief. If you are good at something, it limits the effort you put into it , because you believe you are just good. If you are bad at something, it makes you give up. This belief is useless and only stops people from improving.
---
Have more questions?
Friday, May 31, 2013
Script to recover the old gmail favicon
Update: I've noticed this is getting many page views lately. Unfortunately, it no longer works. Google learned about leaving their old icon in the servers and changed it too. The only solution I can think of is hosting the old icon somewhere else and changing the url in the following script to use that hosted icon.

Yesterday gmail changed the favicon.
I don't like the new one. I wonder if the designer has ever witnessed the effects of lightning in a real life envelope. Shadows don't do that :).
This is serious business for me, because I am in front of a computer most of my life. And most of the time I am in front of a computer, it is looking at my browser window. And most of the time I am looking at my browser window, the gmail icon is the one in the first pinned app.
But I am a programmer, and I know how to workaround issues. I always have greasemonkey installed in firefox. It is an addon that allows me to specify some javascript scripts to run when visiting specific pages. All I had to do was to create a script that could change the favicon...
With some research, I found out that when google changed the icon, they didn't replace the old file. Instead they just created a new one. So all that the script needed was to change the address. A google search for "Change favicon with javascript" took me to a stackoverflow thread: http://stackoverflow.com/questions/260857/changing-website-favicon-dynamically/260876#260876
So here is the link to the userscripts.org entry: http://userscripts.org/scripts/show/169207. And here is the script itself:
// ==UserScript==
// @name old favicon
// @namespace nouglyenvelopeshadow
// @description Changes gmail's favicon back to the old one
// @include http*://mail.google.com*
// @version 1
// @grant none
// ==/UserScript==
(function() {
var link = document.createElement('link');
link.type = 'image/x-icon';
link.rel = 'shortcut icon';
link.href = '/mail/u/0/images/favicon.ico';
document.getElementsByTagName('head')[0].appendChild(link);
}());
Sunday, May 19, 2013
Life with chronic headache
In two days I am going to reach a important milestone. My headache is going to turn 4 weeks old! Imagine that. It is a very weak headache. If you want to feel how I feel, grab a shirt, make it a ball and put it above your head. Now imagine it is above your head all the time. E.g: When you wake up. Now imagine the shirt is invisible, so you shouldn't be feeling the shirt. Now imagine that the shirt becomes heavier during the second half of the day. It is mild, so mild that for days I was not sure it was a headache, maybe it was a numbness? But when I describe it to people they say it is what they often feel and call a headache. Doctors don't seem worried, it is either tension in my neck or a transformed migraine. But it is difficult not to focus on the fact that it is about to reach its fifth week!
The most likely explanation is that the stress I was going through one month ago somehow triggered this. It could be the cause of the tension in the neck. Or it could have been the thing that transformed my migraine.
Surprisingly productive
Because it is such a weak headache and because distracting myself with things, the first weeks were surprisingly productive. The more I worked or exercised the less I would get to feel/remember the stupid ache.
This may be the reason I was actually able to score a SRM problem set. I know that the problems really sucked this time. But keep in mind that I have been going through a long dry streak before this, not being able to think of problems.
Attempts to get rid of it
So if it is tension, you try to relax. It sounds so easy, really. Although quite honestly, I don't feel as stressed as one month ago. I really think I am calmer now. But maybe I am not. In attempts to relax, I tried massage with a stupid automatic chair called ceragem. I was wary of this because of all the new age rubish it promised. Then I tried it and it was awful. Do you remember "Modern Times"? I refer to the scene in which the poor guy falls into the factory's gears. It feels like that, but also with heat. The good thing about this torture is that at least it distracted from the headache. But no thank you. Not worth it. Not worth it at all.
The sleep thingy
A study with more than 40 women that had chronic headaches, split the group of people in two. They gave instructions about sleep habits to half of them. And placebo instructions (Fake instructions that sound like health advice but are not supposed to do anything) to the other half. Apparently a good quantity of women from the first half eventually reverted back to episodic headaches (Which is the best I can hope to get, not to cure my headache but to return to the good ole days in which headaches happened only once every two weeks). I figure that the 5 sleep habit instructions probably can't hurt (plus they are things that are usually agreed to be healthy things to do), but if they worked it would be wonderful:
- Keep a strict sleep schedule. Always 8 hours. Always going to bed at the same time (allowing a 30 minutes variation). Always wake up at the same time.
- No watching TV, no reading, no music while you are in bed.
- Using a visualization technique after getting to bed so that you start to sleep without distractions
- Avoid eating 4 hours before bed time. Drinking 2 hours before bed time.
- No naps. Not even if you are sleepy. Not even if it is fun. Not even with permission from your mum.
Oh boy, so I thought to myself. "Ok, I have basically no strings attached to me that would stop me from keeping a sleep schedule. So this is doable". Years ago I bought the idea that you only need 6 hours of sleep, or perhaps only four and that it was wise to only go to sleep when you are feeling sleepy. So I stayed in front of the computer up until 2:00 AM most nights. Slept around 5 hours a night in average, and maybe took short naps at the afternoon. I thought this was a clever way to do things, and definitely, with time I ended up not needing a lot of sleep a day... ... But now, if losing this sleep superpower was the price to pay for not having a constant headache, it seemed worth it...
Keeping a consistent sleep schedule...
It turns out that this was incredibly difficult. First of all, since my bed time and my awake time have to be roughly the same every day (EVERY day), I had to be careful picking the times. I picked 11:00 PM - 7:00 AM. Because I need to wake up at 7:00 AM to take my blood pressure medicine. This instantly kills my aspirations to participate in morning SRMs :(. But there is no other way, I guess.
However, my body is not very used to the idea of sleeping 8 hours. And throughout these 2 weeks I have been trying this sleep schedule, I have constantly waken up in the middle of the night. Feeling without any need to keep sleeping. But I have to go back to sleep or else the change in sleep habit is not going to have a real effect. I think there is a link between the headache and sleep, because on the days after the nights in which I sleep less time, my headaches are a bit worse.
No doing anything in bed
This is incredibly difficult to me. And honestly, it is almost a 1st world advice. I think people who own a real house can probably afford having all their stuff outside their bedroom. In my case, we have four people living in the same apartment. My bedroom is the only place besides my computer desk where I can work at. I don't have space anywhere to store my LEGO sets and tons (and tons) of bricks inside tupper ware (Really, I have tons of LEGO bricks, tons). So my bedroom was the only place where I could work on LEGO stuff. So far I am quiting my LEGO hobby at least for a while, because I can't do anything on bed. Also, my consoles and my TV are at my bedroom. There is no space elsewhere. So lately I only have my computer and my bedroom is deserted, not sure what to do with this. (No, seriously, I have so many bricks, all classified and sorted by shape and color, that I have almost no space in my bedroom).
Visualization technique?
Nah it sounds silly, plus I can start to sleep without much issue. It is the waking up in the middle of the night that is tormenting me.
No naps
The point of not having naps during the day is that it will allow you to go to sleep easily at the scheduled time. It works in theory. But some days it gets difficult because you didn't sleep too well last night. Although lately my body has been getting used to this.
No eating/drinking too late
This is another thing that is not very viable. So I go to sleep at 11:00PM. It means that in order to eat four hours before bed, I would have to finish eating at 7:00. It is impossible for there to be food at home before 8:30 PM. Sometimes we eat at 10:00 PM. This is something I can't help.
The study said that all the women who followed all FIVE new habits reverted their chronic headaches to episodic ones. But missing one of the habits reduced the probability of success. Since I can't do many of these habits and one of them is rubish, then all my success rate depends on putting all my strength and will power in the sleep schedule, not doing anything other than sleeping in bed and not having naps. These changes have been the most difficult change ever. And I say this after the month in which I successfully switched to eating only 50% of what I used to eat and doing regular exercise. It is incredibly difficult to wake up at 6:00 AM and not just go the computer. It is also difficult to wake up at 7:00 AM, and not stay in bed 5 more minutes. Actually, I miss staying in bed without doing anything. Now whenever I am in bed it is me trying to sleep.
Oddly productive
But there is something surprising about the new sleep habits. What is true is that I now have far less time to use my computer than before. I spend more time in bed trying to sleep. And I think that I am sleeping more time than I became used to sleep these last 7 years. But the strange thing is that I feel more productive. I think that before I had more time, but I used to spend plenty of that time in doing nothing. Instead , this month I would do strange things like write an editorial, write a compiler (From working C-like syntax to GNU assembly code) and continuously improve solutions for a TopCoder Marathon. All at once during the same week. I don't remember the last time I was this productive. But I suspect it was since before I started to sleep only at 2:00 AM. Although this could all be the placebo effect.
Leaving coffee
Something funny happened last month when I was trying to stop having stress. I decided to quit coffee. A week after I quit coffee, I noticed I was feeling worse, so I starting drinking it again. It is likely a coincidence, but 1 day or maybe 2 days after I started to drink coffee again, the headache started. So I stopped the caffeine once again a week ago. This last week has been miserable, because lack of caffeine apparently has a withdrawal effect. This is a very hard change, because I used to drink two cups of coffee a day, one during breakfast and one at the afternoon (A meal that around here is called "Tea time".) No offense to milk drinkers. But milk is really not as delicious as coffee. In fact, I't rather drink plain water, and that is what I have been doing during the afternoon "Tea time". Water. Just water. During the breakfasts, I just fill my cup of milk with a ton of corn flakes. They distract me from the awful flavor of milk.
It is going to be a long battle
If tomorrow, when I wake up, it turns out I do not feel anything funny in my head. It will be the happiest day of my life. However, I think I stopped having such a hope after the 9-th or the 10-th day of really thinking that maybe the next day was going to be the day. Eventually, the headache will end, but it is likely going to take a while. It could end after a whole year or it could end tomorrow. I have no idea.