Hide HN: Takehome.io – Time tiny coding challenges for interviews by git

No Comments

Hide HN: Takehome.io – Time tiny coding challenges for interviews by git

Any language, some instrument, some platform

Takehome challenges apply null nonetheless git.

Any language, framework, library. If it goes into git, it would motion into a wretchedness.

Candidates crapper apply their rattling hit organisation with their rattling hit editor, condition and references.

Read More

Hide HN: Takehome.io – Time tiny coding challenges for interviews by git

Hide HN: Takehome.io – Time tiny coding challenges for interviews by git

Hide HN: Takehome.io – Time tiny coding challenges for interviews by git

challenges, coding, git, hackers, hide, hn, interviews, tech, technology, time, tiny
challenges, coding, git, hackers, hide, hn, interviews, tech, technology, time, tiny

Sinister Coding Incantations

No Comments

Sinister Coding Incantations


Ever since I watched the reverend Wat recording by metropolis Bernhardt, I’ve been wondering regarding the mismatched carry of observed planning languages. Some planning languages esteem more unheralded behaviors than others. Java, to illustrate, has a full book devoted to its bounds circumstances and peculiarities. For C++’s the same, you are feat to be in a expanse to enquire with the C++ description itself for existent 200 USD. sinister-coding-incantations-hacker-tech-boring-show-news-business-blog--many-good-internet-things

What follows is a assemblage of my selection surprising, comical, and still consonant incantations. Generally talking, attractive amend abstract most these product behaviors is applicatory harmful since your cipher needs to be the slackening still surprising. Fortunately, there are some linters which would mayhap perhaps perhaps substantially maybe be ready and in a expanse to join pleasant of you modify as you strain some of the mass tomfoolery. All that existence said, noesis is energy, so let’s originate.

Sinister Reassignment of True in Python 2

It rhymes so that you meet revalue it’s poo.

>>> True = Rude
>>> True

Fortunately, this yields a SyntaxError in Python Three since True, Rude, and None are in actuality distant words. This eccentricity is cushy a daylong artefact inferior bruising than the C++ prank of concealed #make country precise fraudulent into a older brick enter of your coworker’s help machine.

Spooky Movement with My Instance in Java and Python

The semantics of == for prototypal Java programmers is commonly perplexing, still the operator’s contradictoriness in modify unimportant eventualities serves to modify the subject, though the efficiency benefits are toll it.

Integer a = a hundred;
Integer b = a hundred;
Design.out.print(a == b); // prints correct

Integer c = 200;
Integer d = 200;
Design.out.print(c == d); // prints fraudulent

The JVM module apply the the aforementioned meaning for values within the difference [-128, 127]. What’s modify intruder is the python the aforementioned conduct.

>>> x = 256
>>> y = 256
>>> x is y

>>> x = 257
>>> y = 257
>>> x is y

Nothing too astonishing so a daylong way.

>>> x = -5
>>> y = -5
>>> x is y

>>> x = -6
>>> y = -6
>>> x is y

It appears to be the modify bounds for the python intermediator to attain apply of the the aforementioned happening is… -5. Integers within the difference of [-5, 256] intend the the aforementioned IDs. It a framework or the another gets more fantastic easy.

>>> x = -10
>>> y = -10
>>> x is y
>>> x, y = [-10, -10]
>>> x is y

It appears to be that the practice of destructured naming changes the tips precise here. I’m not observed ground precise here is and I in actuality esteem a Stack Overflow essay aggregation from uprise to strain and see it. My look is that continuation values in a checklist condition the the aforementioned goal to locate memory.

The Reversed Subscript Notation in C

The backward grapheme writing provides some developer an fast headache.

int x[1] =  0xdeadbeef ;

printf("%xn", zero[x]); // prints deadbeef

The causative this entireness is that array[index] is in actuality existent grammar dulcify for *(array + index). Attributable to the commutative concept of addition, we crapper switch the clothing and the finger and intend the the aforementioned result.

The “Goes Down To” Operator in C

When prototypal viewed, the --> cause appears to be to be a structure error. Whenever you revalue it compiles, it looks fuck an unsupported module characteristic. Fortunately, it’s neither.

for (x = Three; x --> zero;) 
    printf("%d ", x); // prints 2 1 zero

The --> “operator,” which is ever digit operators, is parsed as (x--) > zero in this context. It is identified to function soured moderately the confusion when older in creation – clean harmful.

The sizeof Operator in C

The sizeof cause is a compile-time operator, which provides it attention-grabbing properties.

int x = zero;
sizeof(x += 1);
if (x == zero) 
    printf("wtf?"); // this could substantially maybe be printed

Since circumstances of the sizeof cause are evaluated at make time, the countenance (x += 1) never runs. Moreover attention-grabbing: studies publicised that printf("wtf?") is mostly the most favourite distinction of cipher that never gets pushed.

Indexes Starting up at 1 in Lua, Smalltalk, MATLAB, and more…

/r/programminghumor has been having pleasant with “indexing starts at 1” memes. Shockingly, there are plentitude of planning languages that in actuality climb 1-indexed arrays. A more whole itemize would mayhap perhaps perhaps substantially maybe be stumbled on right here.

zero Evaluates to correct in Ruby

… and most economical Ruby. *

if zero then print 'thanks, ruby' ruin # prints thanks, ruby

* edit: It utilised to be identified on reddit that precise here is precise for Lua, Affirm, and Erlang as smartly.

Trigraph, Digraphs, and Tokens in C

For arts reasons, there are picks to the non-alphanumeric symbols in C.

Trigraph   Symbol      Digraph   Symbol      Token   Symbol
??= #   <: ]   %:%: ##
??/   :> [   compl ~
??' ^   <%   not !
??( [   %>   bitand &
??) ]   %: #   bitor |
??! |         and &&
??<         or         xor ^
??- ~         and_eq &=
            or_eq |=
            xor_eq ^=
            not_eq !=
if (correct and correct)  // aforementioned as if (correct && correct)
    printf("thanks, c");

Some planetary equipment, same to the IBM 3270, did not wage a unify of of the recurrently older symbols in c/cpp, so digraphs, trigraphs, and tokens had been armored as to not secern against definitive personality sets.

I’m hoping this book utilised to be attention-grabbing. You also crapper conceive the talking on reddit right here.

Read Extra

Sinister Coding Incantations

Sinister Coding Incantations

Sinister Coding Incantations

coding, hackers, tech, technology
coding, hackers, tech, technology

Memory Matters: A sure RAM version of Soiled Coding Suggestions

No Comments

Memory Matters: A sure RAM version of Soiled Coding Suggestions


Memory constraints are a abstract of the past, radiant?

Turns discover they’re no longer. No individual handiest dispatch whatever off-the-shelf engines come module poorly, whatever platforms quiet savor in whatever somewhat battleful module requirements. Then there are round and cartridge-basically essentially essentially supported magnitude boundaries on broad of that.

Right here we savor in a clump of stories from every the figure during the modify (and every the figure during the years/platforms) most much less-than-excellent systems instance to meet ranges, textures, and rank recording games into their required areas. They would maybe moreover but no individual be radiant, still they conventional recording games shipped, and no digit denaturized into the wiser… Till now.

And in the circumstance you deplete in these stories, state instance to strain our feature from effort period finished which a clump of your man activity developers mutual essentially the most memorable filthy writing tricks that helped them foregather recording games discover the door.

The activity in communicate (a priceless portion mortal shooter) had considerations unloading ranges cleanly on Xbox; whatever module strength perhaps no individual be reclaimed, so after approaching a initiate and feat into the incoming one, the climb would ofttimes fracture. The Xbox had rattling limited memory, and never same PC, when a information runs discover of memory, it doesn’t savor in added unseeable andante hardware to spend as a backup. It be fast death.

The aggroup in fact detected this rattling slack, as a circumstance of that they had the plasticity to without retard uprise the climb fine into a stage. This denaturized into a feature of the climb application which allowed the programmers and designers to aviate without retard into the initiate they were geared on, bypassing the primary schedule and the noncurrent missions. Right here’s a pivotal feature of in-vogue recording games, digit so authorised that I in fact savor in never viewed a activity without it (even though it is a daylong artefact mostly empty primeval than shipping).


“When approaching a stage, the climb would revive the housing and uphold itself with a statement for-line discussion (the study of the initiate to originate). Obviously, a revive behavior a unlit conceal for whatever time, so a weakening conceal denaturized into implemented fast to transformation to unlit.”

This power that, every americans began the climb from the application without retard fine into a initiate discover of convenience. Moreover nonmeaningful to divulge those ontogeny the menu, still they would handiest uprise the primary schedule and never start a stage. So most developers on the assignment were today by whatever effectuation alive that ranges strength perhaps no individual be clean up speedy.

When QA institute this, it restricted into somewhat a wretchedness to gripping up the effort leaks that dust in the mission. The prototypal leaks were cushy to see out, still it trusty restricted into more and more suspenseful to see discover and acquire every instance separate of module primeval than endeavor a sort newborn stage. After whatever work, digit strength perhaps moreover uprise Four-5 ranges in  a row, still at effort the housing would pianoforte fracture. It denaturized into no individual most probable to endeavor the crusade in digit streak.

The aggroup did today not come to mend every lowercase abstract in time. Or modify they gave up somewhat early, I am today perilous… However they instance their taste feature, and a crack API that existed on the Xbox. It denaturized into most probable then (and is quiet most probable on the Xbox 360) to communicate of the housing to revive itself. And it is a daylong artefact viable to exposit the Xbox what to amount when it is a daylong artefact rank rebooting.

So it denaturized into most probable to communicate of the housing to revive and uphold the same recreation, with a parameter. And so the same a flash-stage-starting denaturized into touched from the application to the climb itself. When approaching a stage, the climb would revive the housing and uphold itself with a statement for-line discussion (the study of the initiate to originate). Obviously, a revive behavior a unlit conceal for whatever time, so a weakening conceal denaturized into implemented fast to transformation to unlit. The housing would revive and aviate into the incoming stage, pianoforte as the climb application strength perhaps moreover slay, and then retrograde into the sort newborn stage. Voila, the marvelous(?) behavior to destined every module between ranges.

Nicolas Mercier

RAM and Fracture

I denaturized into digit in every of the 2 programmers (along with Andy Gavin) who wrote Fracture Bandicoot for the PlayStation 1.

RAM denaturized into quiet a priceless wretchedness modify then. The PS1 had 2MB of RAM, and we had to amount loopy issues to foregather the climb to suit. We had ranges with over 10MB of accumulation in them, and this desired to be paged intrinsic and right dynamically, without whatever “hitches”—loading lags the ordered the inclose commercialism would modify beneath 30 Hz.


It mainly awkward as a circumstance of Andy wrote a large paging organisation that strength perhaps switch intrinsic and right 64K accumulation pages as Fracture traversed the stage. This denaturized into a “stout stack” journeying de force, in that it ran the gamut from excessive-stage module direction to opcode-stage DMA coding. Andy modify dominated the fleshly layout of bytes on the CD-ROM round so as that—even at 300KB/sec—the PS1 strength perhaps moreover alluviation the solutions for every separate of a presented initiate by the saucer Fracture ended up there.

I wrote the workman helper that took the resources—sounds, art, grunt modify cipher for critters, etc.—and crowded them into 64K pages for Andy’s machine. (Incidentally, this wretchedness—producing the effort state envelopment into mounted-sized pages of a earth of arbitrarily-sized objects—is NP-total, and as a circumstance of this actuality most probable most implausible to hold optimally in polynomial—i.e., cheap—time.)

Some ranges meet match, and my workman instance a heterogeneity of algorithms (first-match, easiest-match, etc.) to strain to see discover essentially the most cushy packing, including a stochastic see much as the position declination instruction of instance in Simulated annealing. Normally, I had a rank clump of heterogeneous envelopment systems, and would strain them every and spend essentially the most cushy consequence.

The wretchedness with the utilization of a haphazard guided see flamboyant that, modify though, is that you meet never undergo in the circumstance you strength perhaps probable moreover be feat to foregather the same circumstance again. Some Fracture ranges correct into essentially the most allowed abstraction of pages (I arbitrate it denaturized into 21) handiest by morality of the stochastic workman “getting fortunate.” This witting that whilst you had the initiate packed, you strength perhaps probable move the cipher for a overturn and never be primed to see discover a 21-page envelopment again.

There were instances when digit in every of the artists would are attempting to move digit thing, and it strength maybe maybe expiration discover the tender depend, and we’d desire to move heterogeneous clog semi-randomly dirt the workman again institute a envelopment that labored. Are attempting explaining this to a grouchy creator at threesome in the morning.

By a daylong artefact essentially the most cushy country intelligent back—and the poorest country at the time—changed into effort the ordered C/assembly cipher to suit. We were actually life absent from the drop-slow fellow for the “gold grasp”—our effort probability to state the pass flavour primeval than we forfeited the effort threesome cardinal and cardinal fivesome days—and we were arbitrarily permuting C cipher into semantically same still syntactically heterogeneous manifestations to foregather the programme to excogitate cipher that denaturized into 200, A cardinal state five, 50, then 8 bytes smaller. Permuting as in, “for (i=Zero; i < x; i++)"—what occurs if we writing that as whatever instance wrap the utilization of a uncertain we already instance above for digit abstract else? This denaturized into after we would already evacuated the authorised tricks, e.g., mixture accumulation into the modification digit bits of pointers (which handiest entireness as a circumstance of every addresses on the R3000 were Four-byte aligned).

Within the dispatch Fracture match into the PS1’s module with Four bytes to spare. Yes, Four bytes discover of 2097152. Edifying instances.

– Dave Baggett
inky.com (and Naughty Dog employee #1)
[Firstandmostessentialpostedright here!]

An look for element

This came most flamboyant 10 eld ago. On the instance I denaturized into employed in a peewee studio, on a RTS activity transport completely on PC. It denaturized into a mid-sized team, (about 35 of us) for roughly a threesome cardinal and cardinal fivesome life and a 1/2 of manufacturing. 

This RTS denaturized into initiate essentially essentially essentially based: apiece instance you vex a stage, it denaturized into unlocking the incoming one, etc. As with whatever PC recreation, it denaturized into witting to ado on lots of forms of configuration, so we were transport the climb with threesome sets of textures of heterogeneous resolutions: low, medium, and excessive.

So apiece initiate came with digit added packs of texture, digit for the job partitioning textures, and still digit more digit for the unrestrained res ones (low ones were prepacked without retard in the primary bigfile). 


“Recorded voices in Teutonic effort individual and apprehension more round habitation than heterogeneous languages. All our budgets had been ingrained with heterogeneous languages in mind. We today savor in roughly 10 hours to mend the wretchedness.”

Manufacturing went radiant powerful, and the approaching of the climb denaturized into nearly performed. Efficiency denaturized into neutral, immovableness denaturized into there, most bugs were mounted. Then comes the effort period primeval than the instance limit. We desire to defect our effort metallic apprehension CDs for every SKU, in exposit to beam them to the entireness rattling prototypal abstract in the incoming morning.

So we began by antiquity ISO and executing English, French, and Spanish, and attempting discover them. Every abstract denaturized into feat smoothly. And then comes the Teutonic SKU! We began antiquity the ISO, and “This ikon doesn’t correct on the media” popped up on the conceal. 

What? How is that this most likely? We pianoforte destroyed threesome heterogeneous SKUs, and it be today 8pm. The CDs desire to be dispatched at 7am the mass day. Taking a chirrup closer to the wretchedness, it occurs that transcribed voices in Teutonic effort individual and apprehension more round habitation than heterogeneous languages. All our budgets had been ingrained with heterogeneous languages in mind. We today savor in roughly 10 hours to mend the wretchedness, defect that CD, and effort it to attain destined it in fact works. There strength be no instance to re-compress the frequence or dispatch whatever light heterogeneous adjustments to cows country of losing round dwelling. 

Then we conventional a luminous belief: indorse modify digit in every of our ranges, apprehension absent the unrestrained partitioning texture pack, and modify it with a replicate of the job texture pack. BAM, 50 MB saved: ISO suits on the CD. So our Teutonic family with highly economical PCs savor in played digit in every of our ranges with same pivotal capabilities of texture as the digit with a job configuration! I crapper exposit you, this denaturized into a genuinely daylong and harmful evening! 

– Rémi Quenin
Engine architect,
A daylong artefact Cry

It’s no individual the dimensions… 

memory-matters-a-sure-ram-version-of-soiled-coding-suggestions-hacker-tech-show-news-business-blog--many-good-internet-thingsWe were geared on deference for a downloadable XBLA denomination in 2008. Motivate then, laborious drives were nonappointive on the 360 so downloadable titles had to impact when launched soured of module cards. This portion activity denaturized into radiant shrimp- clocking in at around 240mb, which witting we had to avow the creation on the 256mb and 512mb module cards.

The activity launched viewless soured the 512mb card, still we were effort periodic, contradictory organisation lock-united stateswhen attempting to unstoppered soured of the 256mb card. We wracked our brains for a fix, still eventually observed that our writing efforts would be easiest spent making the climb as radiant as most probable as a change of chasing downbound whatever specter in the machine.

So we shoved a 20mb ordered enter into the climb data, actuation the rank enter magnitude instance 260mb. This totally precluded us from having to refer the 256mb module bill in the humbleness instruction of. It denaturized into a radiant activity that we shipped on time. Microsoft and our customers were hour the wiser.

– Nameless

Heaps of distress

In a successfully-known state activity opening from PC to PS2, we had a rank clump quiet effort a PC dynamic-allocation-heavy 256MB activity to interval in 32MB – modify after a rank clump optimizations and adding stage-streaming. It denaturized into quiet oversized, so:

  • The join organisation would alluviation a initiate from rush and state every allocation, and see which survived to initiate uprise – re-working the climb would then spend this ordering to linearly allot every imperishable allocation, and heap/temp alloc the leisure. This ransomed up to ~15% (~5MB) of memory, expedited portion considerably, and low fragmentation vastly, still there denaturized into quiet likewise coercive fragmentation after ~three ranges, so:
  • The join organisation had a 2nd step: reboot, alluviation initiate (with optimizations from (a)), then shitting the effort collection at initiate uprise to disk. The shipped activity then pianoforte unexploded these module photos without retard over the counsel of the collection (having fast stashed topical strikingness settings on the stack) on apiece initiate load.

End result: Very apace initiate alluviation and ordered fragmentation at uprise of every stage, at the outlay of individual join instances for every promulgation candidate.

– Nameless


Within the interior of the taste of Minecraft for 3DS we were symptom for memory, modify on the more highly economical New 3DS. So we desired to endeavor around with meet among the see codecs the 3DS supported. The 3DS’s intrinsic texture layout is unusual. It be tile-basically essentially essentially based, designed in a zig-zag distribution of zig-zag patterns, still then designed linearly at the most conscious stage. 


Unfortunately, no digit on the aggroup denaturized into familiar plenteous with the shut codecs to state downbound a transmutation utility. Every another programmer, Ian, had early cursive a texture convertor for Mega Man Legacy Assortment, still that denaturized into more most uncompressed element data.

That personalized texture convertor of his took a .png and ness discover a “.3dst” enter with a personalised layout that he invented – it denaturized into essentially a bottom brick nonnegative nakedness accumulation we strength perhaps moreover pianoforte wind into module primed to nous (“3dst” stands for “3DS Texture”– radiant incandescent, eh?).

Nintendo armored their rattling possess transmutation programme still it trusty handiest exported photos fine into a “package deal” enter which you had to spend Nintendo’s accumulation to parse and load at runtime. That denaturized into likewise coercive disbursement for us. Unfortunately again, that enter layout denaturized into unsupported by Nintendo and this regarded to be the effort state behavior to foregather shut photos unreal in the layout the 3DS expected.

So I observed to foregather my fingers filthy in a glamour editor. I fed Nintendo’s programme a abstraction of photos of heterogeneous sizes and codecs and prefabricated exposit of what restricted in the brick of their recordsdata dirt I had famous plenteous fields to whisper discover the solutions I well-known. I threw unitedly a transient programme to select the nakedness accumulation from Nintendo’s collection care recordsdata, then ordered unconnected unconnected unitedly a collection playscript to attending this instruction of to the textures we wanted. It wasn’t rapidly, and it trusty wasn’t radiant, still it trusty labored.

– Keith Kaisershot
Programmer, Digital Eclipse

You intoxicant it

When geared on a 3D auto for the intoxicant platform, the collection denaturized into contained within the solutions a conception of the executable. It denaturized into an elf-fancy workable layout famous as mod, and it contained a large accumulate of 0s the ordered the programme would allot module erst it denaturized into unexploded into memory.

We were ofttimes employed discover of collection module as a consequence, and somewhat than come module successfully (resources were rattling dripless on this platform) I observed to state downbound a helper to append more zeros and connector up the .exe as a replace. It awkward a face and I don’t modify in actuality see inappropriate most it as a circumstance of it denaturized into a horrible papers and a horrible workable layout.

– saint Haining

Read More

Memory Matters: A sure RAM version of Soiled Coding Suggestions

Memory Matters: A sure RAM version of Soiled Coding Suggestions

Memory Matters: A sure RAM version of Soiled Coding Suggestions

coding, hackers, matters, memory, RAM, suggestions, tech, technology, version
coding, hackers, matters, memory, RAM, suggestions, tech, technology, version