Skip to main content

Posts

Showing posts from 2017

How I Imagine Daily Life of Yugioh's Developer

1. Gemini Monster. Game Designer: Hi dev, you still remember those normal monster? Dev: yeah, sure Game Designer: I'd like to add a few of them. Dev: Ok, doesn't need lot of code. Game Designer: Here's the tweak.. It is first treated as normal summon, and then when it is on the field you can normal summon it again to make it an effect monster. Off course, when it dies, it's a normal monster again. Dev: Wat... Conclusion: Yeah, let's make an effect monster with an effect that treated as normal monster and can be summoned twice. 2. XYZ Summon Game Designer: We need new summon mechanic Dev: OK. Game Designer: let's call it XYZ summon so the XYZ monster, should first be in the extra deck. Dev: Ok. Game Designer: well, you can summon it similar to synchro and fusion, except when it is summoned, you put the materials below it. Dev: That's a pain. Game Designer: Oh and monster that become material doesn't treated as le...

Facebook Hacker Cup Qualification Round - 2017

This is probably the first time I've ever solved all problems in Programming Competition. So, as to commemorate the event, I'm writing my solution about the problems. Problem 1: you can view it  here . question: given N percentage of a circle with radius 50 and center at (50, 50), determine whether point at (X, Y) is within that circle or not. Answer: This problem is quite obvious, in this problem we just need to figure out the degree and distance of (X, Y) from (50, 50). The distance can be measured using basic trigonometry r = sqrt(dx^2 + dy^2) The degree can be measured with arccos(dx / r) Though we'll need a little tweak based on which quarter it's placed on. tag: Mathematic, Trigonometry, Implementation Problem 2: can be viewed  here . problem is too long to be explained, checkout that link. Answer: This is a problem where, if you feel confused, just try to implement it. The solution here is just to order the items in the descending order ...

Ruby, Metaprogramming, and LinearEquation Solver

Metaprogramming Metaprogramming  is a  programming  technique in which computer programs have the ability to treat programs as their data. It means that a  program  could be designed to read, generate, analyse or transform other programs, and even modify itself while running. ~  Wikipedia . In Ruby, there's an enormous amount of function, that would help you writing a program, that could dynamically modify itself. Most common example is: define_method(methodname, &block) define_method is a method that take two argument, a symbol or string as the methodname, and the block process of what it should do. for example, if I have a class, that refer to a user table in mysql with field name, email, and password, i can define 3 new method dynamically, namely find_by_name, find_by_email, and find_by_password with the following code: (not accurate, but you get the point) method_missing?(methodname) method missing is a method that just accept a...