Profile

Cover photo
Giacomo Sorbi
Attended SSSUP Sant'Anna
Lives in Milan
467 followers|341,793 views
AboutPostsPhotosVideos

Stream

Giacomo Sorbi

Shared publicly  - 
 
#javascript#combinatorics  and some fun discussing with friends my ideas for some function aimed at shuffling or getting combinations out of an array (but you can easily generalize it to strings or other enumerables).

As the discussion was getting interesting, mostly thanks to the quality of the feed from my acquaintances, I decided to move it in public, so feel free to comment, contribute or, why not, criticize :)

Starting with the shuffle function, first of all I decided I wanted to make it an array class method (as it is the case in Ruby) and not a mere function (as it is the case in Python, getting it from the random library) so that I got both a step away from Python's mindset (I really love Python, but I prefer not to be to dependent on a technology and to keep my mind elastic!) and a chance to make some practice with the prototype model of JS.

Then I developed it in a concise and elegant way, only requiring 3 support variables.

I know I may sound clichéd as an Italian focused on frilly elegance, but I discovered that style does matter: if you can read and think in smooth patterns, then you will do it more often and more efficiently :)

I also know that the CLRS teaches us all that probability-distribution-wise you should also run j to be chosen in a more restricted range at each step, but as I find it more easy, again elegant and quick to write that way, I kept getting a random j variable from all the values from 0 up to array-length.

Plus, I usually use it on very short (<20 elements) array that get shuffled many times over in my random tests, so the difference is really minimal in the long run :)

Notice the for loop, missing the third element (usually the incrementator/decrementator statement), as guess what? It is optional!

And so, just initializing the i variable = to the array.length, I got to write the simple and graceful for (i;i;)* statement.

I could do that also because I used the pre-put "-" operator in the instructions to be operated inside the loop): notice that if I were to write "i-" instead of "-i", the variable would not have been decremented first, so my method would not have worked (not as expected, at least); another option was to initialize i as array.length-1, but I found the way I choose more neat, not to mention it forced me to remember how the "-" or "++" operator work according to where you place them :)

Finally, I opted to have a method that worked both in place (as with Ruby) and returning a new array (as in Python) for more comfort of use; you could turn it to work only in place removing the final return statement or to work only returning the array without actually touching the array if you worked on a temporary array instead.

And that's all for the shuffle method and for now; I hope I was of some help and interest to whoever will read this :)

#permutation   #combination   #algorithms  
Run code in a variety of languages from your browser
2
Gaurang Tandon's profile photoGiacomo Sorbi's profile photo
2 comments
 
See you on a more free time, then°°/
Add a comment...

Giacomo Sorbi

Shared publicly  - 
 
The Finn scholastic excellence: not only they bestow upon their few citizens one of the top ranked #education  in the world, at least according to the widely adopted (and discussed) PISA ranking, but they even show the guts to risk and change their winning machine.

In the close future they may go so far as to stop teaching notion by subjects (math, philosophy, english...), anchoring them to a broader approach to education that will promote multi-disciplinarity and collaboration. Even among teachers, that for now seem to be quite conservative on this issue.

Will this reform finally reach each class in Finland and will the world follow their example?
For years, Finland has been the by-word for a successful education system, perched at the top of international league tables for literacy and numeracy.
7
1
Amilcare Dal Pino's profile photoGiuseppe Seminara's profile photoGiacomo Sorbi's profile photoAntonio Ardito's profile photo
6 comments
 
Your first step toward Finland :D?

Seriously, I don't expect the extremely static Italian academic system to move in that direction in the next few tens of years. And even then, they could just to it our of sheer peer pressure...
Add a comment...

Giacomo Sorbi

Shared publicly  - 
 
And when you less expect it, a ministry finally comes out with a decent #marketing   #campaign  to promote Italian excellence.

I don't feel Italian at all, but I salute with favour even just the mere fact that it is not more just about shoes&food, telling that tourism is #Italy 's oil or hearing the implausibly crappy English of people like rutelli, berlusconi or renzi.

I don't know even how correct the figures are there, but at least Italy got a professional promotion with a good message: good :)

#advertising   #promotional   #video   #expo2015   #italianstyle  
4
2
adriano gozzo's profile photoGiacomo Sorbi's profile photoRaffaele “Haruki” Procentese's profile photoGiuseppe Seminara's profile photo
12 comments
 
Oh, I missed the verybello initiative: nice and, luckily, a far shot from italia.it \m/

+adriano gozzo, non colgo l'addentellato tra prima e seconda parte della tua risposta: intendi che io sono autoreferenziale allo stato puro e, nel caso, qual è il nesso con l'italianità? O, altrimenti, che altro volevi dirmi?
 ·  Translate
Add a comment...

Giacomo Sorbi

Shared publicly  - 
 
Tsipras' next step: #esproprioproletario  o giù di lì.

Ora immagino che corsa ci sarà a investire in Grecia dopo questa manovrona degna del peggior regime sud Americano.

Tra l'altro non mi è chiaro se intendono sequestrare beni del governo tedesco (poca roba) o appropriarsi indiscriminatamente dei beni di aziende o privati tedeschi, che mi pare più probabile e ben più grave...

E io ancora aspetto davvero che chiedano soldi a Teheran per la tentata invasione da parte dell'esercito persiano un po' di anni prima...
 ·  Translate
Riferendosi ad una decisione pronunciata nel 2000 dalla massima istanza giuridica del paese, Nikos Paraskevopoulos ha ricordato che il provvedimento sosteneva il diritto dei sopravvissuti della città di Distomo a chiedere un risarcimento
27
4
Andrea Borgia's profile photocorrado Ferretti's profile photomixter no's profile photoAndy io's profile photo
221 comments
 
+Giacomo Sorbi ma sei proprio bravo.. a fare propaganda. Ma chi ti paga, vittorio feltri? Magari con la promessa di farti scrivere, un giorno, sul "giornale" vero(è un ossimoro)?
 ·  Translate
Add a comment...

Giacomo Sorbi

Shared publicly  - 
 
Reality 1  - groundless populism 0.

And yet Tsippy dares to talk about political victories, bah... Well, good luck cutting your crazy expenses while keeping your voters happy and dreaming...

#tsipras   #greece   #euro  
7
Enrico Poli's profile photoGiacomo Sorbi's profile photoAmilcare Dal Pino's profile photo
4 comments
 
+Giacomo Sorbi yes indeed!
Add a comment...

Giacomo Sorbi

Shared publicly  - 
 
Most unlucky #marketingcampaign  ever :D?

Just think of a dietetic product with this catchphrase: "Need to lose weight? Get AYDS!"

Needless to say, they didn't sell that much in the 80s...

#marketing   #marketingfail
Here is the story of "AYDS" appetite suppressant. Really. It's more than a bit depressing. And unlike some examples given here, it was a total surprise fo...
1
Add a comment...
Have him in circles
467 people
mariateresa panunzio's profile photo
Dinamiteksrl's profile photo
ruggiero DitePa's profile photo
Giromir Mork's profile photo
Bruno César Bulnes's profile photo
Jackie Navarro's profile photo
Junior Campusano's profile photo
Play Angel's profile photo
marco bulli's profile photo

Giacomo Sorbi

Shared publicly  - 
 
#learning  to #code  (or many other things): the importance of the "no days off approach" in a neat post :)

#programming   #coding
3
Add a comment...

Giacomo Sorbi

Shared publicly  - 
 
Challenged by +Fabio Lombardo, I went on and created some simple (and not quite as efficient as it could be) function to convert numbers into a given base (default: pi, as it was #piday  few days ago).

Not satisfied with my quick and dirty work, I even created an even more inefficient (it does the same operations more than once, but I got lazy because of the hour) that converts back the numbers into decimal.

Change the value of test or just press "Run" and behold all the power of #Python  managed via #javascript  (and thus with some number precision issue, otherwise I would have used the round() function to make it more readable with the unused "decimals" parameter).

It can be improved A LOT, I know, but I learned that this stuff also has some use and it is not so esoteric: http://en.wikipedia.org/wiki/Non-integer_representation

Any comment, suggestion or hooligan-lke bashing on my poor coding skills is welcome as usual :)
Run code in a variety of languages from your browser
2
1
Giacomo Sorbi's profile photoCole Routley's profile photo
 
Most satisfying part: if you put "test=pi", it works as expected :)
Add a comment...

Giacomo Sorbi

Shared publicly  - 
 
Update from #greece : the Hellenic diplomacy is now going for (faintly denied) middle-fingers, after talking about seizing German properties on their soil or letting Germany be flooded by illegal migrants, #ISIS  members included.

I just wonder if they'll stop once they start burning German flags or will sink even deeper into more shameless childish acts...

#tsipras   #grexit   #greek  
He's in hot water in Athens and Berlin, for different reasons.
4
1
Panagiotis Risvas's profile photoMaurizio Di Girolamo's profile photoGiacomo Sorbi's profile photoAndrea Borgia's profile photo
11 comments
 
E che palle la ggente che mi invita a infornarmi (cit.) senza manco saper fornire uno straccio di link.

Oh, io il mio l'ho dato, se poi ti piace commentare e dire la tua, bene. Altrimenti non ci perderò il sonno.
 ·  Translate
Add a comment...

Giacomo Sorbi

Shared publicly  - 
 
Quick-and-not-so-dirty #cheatsheet  about #algorithm ic #complexity  of the most widely used and known algos.

Interesting material in the comments too.
Know Thy Complexities! Hi there! This webpage covers the space and time Big-O complexities of common algorithms used in Computer Science. When preparing for technical interviews in the past, I found myself spending hours crawling the internet putting together the best, average, and worst case ...
2
3
Xuhui Chen (asahui)'s profile photoLeon Wu (凡是自然卷都是好人)'s profile photo
Add a comment...

Giacomo Sorbi

Shared publicly  - 
 
Just in case you need to remind yourself why #php  is not that good language to invest on or why Rasmus Lendorf probably is never getting a Turing Award, a fun reading about what a language should NOT be.

And in case you want to answer, read the last chapters about what not to write ;)

#programming   #phpprogrammer   #phpdevelopment   #programminglanguages  
(This article has been translated into. Spanish by Alpha · Spanish again (PDF, with some additions) by Jorge Amado Soria Ramirez. Thanks!) Preface. I'm cranky. I complain about a lot of things. There's a lot in the world of technology I don't like, and that's really to be expected—programming is ...
3
Alessandro Mencarini's profile photoWade Okumura (tp9)'s profile photoGiacomo Sorbi's profile photo
5 comments
 
I assume you are not referring to php in its hayday :D

Jokes apart, yeah: very nice article, written avoiding both mere ranting and too obscure technical jargon.
Add a comment...

Giacomo Sorbi

Shared publicly  - 
 
Nuova storia di pepputato che, quando la misura è colma, se ne esce e tutto a un tratto ci fa sapere, favia-stye, che nel #m5s , e particolarmente nel #m5sparlamento , il clima era a dir poco invivibile, con zero #democraziadiretta  e tanta, tanta fuffa rovesciata sugli elettori.

Nuova storia, ma niente di nuovo. Non concordo poi sul finale: il controllo totalitario è voluto per soddisfare l'ego malato di due anzianotti in andropausa, con tanta fame di applausi facili oltre che di soldini.

Per il resto, immagino non cambierà idea a nessuno, anche se parla per esperienze dirette sulla passata gestione e rivela come emerganzo i finti leader del non-partito...

#clickbait   #grillini   #movimento5stelle   #movimentocinquestelle   #casaleggio   #beppegrillo  
 ·  Translate
Solitamente non ci interessiamo di politica italiana lasciando questo oneroso compito a persone “più esperte di noi”. Questa volta vogliamo fare una eccezione per il Movimento 5 Stelle o M5S che dir si voglia
12
2
Ennio Chiesurin's profile photoGiacomo Sorbi's profile photoAntonio Ardito's profile photoDaniele Moschetta's profile photo
20 comments
 
Temo che la sola onda creata davvero fosse lo tsunami tour e si sia risolta solo nel fare spumeggiare un po' di € per il signor padrone, stop :(
 ·  Translate
Add a comment...
People
Have him in circles
467 people
mariateresa panunzio's profile photo
Dinamiteksrl's profile photo
ruggiero DitePa's profile photo
Giromir Mork's profile photo
Bruno César Bulnes's profile photo
Jackie Navarro's profile photo
Junior Campusano's profile photo
Play Angel's profile photo
marco bulli's profile photo
Work
Occupation
Web Marketing Specialist
Employment
  • Web Marketing Specialist, present
Places
Map of the places this user has livedMap of the places this user has livedMap of the places this user has lived
Currently
Milan
Previously
Viareggio
Story
Tagline
Marketing & Brand Consultant
Bragging rights
Relentless Insatiable Knowledge Sponge
Education
  • SSSUP Sant'Anna
    Innovation Management and Service Engineering, 2008 - 2009
  • Università degli Studi di Firenze
    Marketing, 2005 - 2008
  • Università degli Studi di Firenze
    Business Administration, 2001 - 2004
Basic Information
Gender
Male