Calcolo numeri primi con espressione regolare
Too good not to repost.
?$ la matcha, allora n è primo.
Perché?
E' composta da 2 pezzi:
^1?$ e ^(11+?)\1+$
^1?$ matcha 1 o la stringa vuota (perché 1 e 0 non sono primi):
^ è l'inizio riga
1? è "zero o un '1'"
$ è il fine riga
^(11+?)\1+$ è più complicato.
l'amico, di noulakaz.net, secondo me la spiega bene dal lato tecnico e male dal lato concettuale.
E' banale. Se n è divisibile per m con 2
Da questa banalità deriva l'idea, che è la seguente: se una sequenza di n "1" è splittabile in 2 o più sequenze di m "1" (con m
Ed è proprio questo che il motore fa. Prende la tua stringa (ad esempio 1111111, cioè 7) e prende "11". A sto punto prova a romperla in uno o più pezzi da "11", ma avanza un "1", quindi non matcha. Poi ci prova con "111", poi con "1111" etc, ma non ci riesce mai.
Con 9 funziona: prova con "11" e non riesce, poi prova con "111" e vede che 9, cioè "111111111" contiene "111", cioè 3, esattamente tre volte, senza resto, quindi matcha.
Con 10 troverà "11", con 12 sempre "11", con 14 "11", ..., con 25 troverà "11111" cioè 5. Si ferma al più piccolo "divisore", per così dire.
E così via. Fa scena, ma in sostanza è obvious:)
So if by chance you will be tomorrow with a machine that only does regular expressions, and you will need to calculate whether a number is prime, you'll know how to do it. Yuppie! : D
<= m < n allora n non è primo.
< n) allora n non è primo.
Friday, July 30, 2010
Wednesday, July 21, 2010
Why Do Europeans Grow Their Pinky Nail
I nome LUUUNGHI
Blend ... but because you have been designed by designer??
:((((
Blend ... but because you have been designed by designer??
:((((
Wednesday, July 14, 2010
Tuesday, July 6, 2010
How To Make Lidocaine Hcl
Country: Volume 1
Faccio una breve analisi personale del calciomercato in entrata della Juve fino ad ora:
DEL NERI:
Approda alla Juve un allenatore umile quanto solido.
Il contratto di benitez era già firmato, pronto all'annuncio ufficiale, quando Agnelli di colpo fa retromarcia. Agnelli ne capisce di calcio, a detta di Moggi, quindi mi fido. Senza contare che come ai buoni vecchi tempi, lo scarto bianconero Benitez è finito all'Inter. Azione con retrogusto nostalgico.
Gigi non ha un palmares ricco, ma è vero che ha avuto a disposizione sempre e solo pseudo-squadrette portandole al miracolo.
Senza contare che anche Lippi (al suo primo ciclo) non aveva won anything.
RATING: 7.5
PEPE:
discrete championship, his last. Flop the world.
E 'was taken in 2.6 million with an option to the right of redemption.
Simone is fast with good tactical intelligence wing, popular features from our new coach.
The flaw is that it is perhaps not yet ripe for a noble team like ours, and perhaps has not developed (by habit) the mentality of "this year should bring home a trophy).
RATING: 6.5 trust
MARTINEZ:
Purchase from 12 million on the nail.
Jorge è un ottimo attaccante, instancabile, veloce. L'unico problema è la fragilità fisica che lo porta di frequente a diversi infortuni, e a vinovo sfonda quindi una porta aperta.
Tuttavia Martinez ha un gioco frizzante, a tratti brasiliano, che gli permette di giocare con spontaneità e non con pressioni addosso. Mi ha colpito nell'ultimo anno (l'ho comprato al fantacalcio sulla fiducia e mi ha regalato soddisfazioni) e soprattutto ha segnato all'inter un goal da antologia. A Catania lo rimpiangono e gli augurano buona fortuna. Ha scelto la Juve benchè la lazio offrisse un ingaggio maggiore.
Cosa principale, e forse più importante di tutte, segna.
VOTO 7,5
STORARI:
excellent goalkeeper, I think.
Buffon out for hernia (operated yesterday, I will tell him what happened as soon touches me : () at least until January, then the door will be bricked by the goalkeeper who has worked very well and even at Sampdoria at Milan.
last year had an average of just under a goal per game now. It seems so, but we had last year by almost two goals against per game. And even some rigor para.
He would preferred only Sirigu.
For him 4.5 million in 3 years.
VOTE 8
BONUCCI:
Leo, for about 15 million are white. True
pin bari that has astounded the defensive in his first year cars.
Great Central had little space and is a national shame as that would certainly better than our Emirate emigrated.
Young, eager to win, coming from the youth of the honest. The same honest
who wanted at all costs, and now suddenly it's better Frogley .. the broken and still half a year.
VOTE: 8
Lanzafame:
I do not waste for the photo, small player, it can also make her but certainly not the big one this summer.
The only semi-positive note: the first two goals della sua vita a Torino contro la Juve, non ha esultato a nessuno dei due goal.
VOTO: 6
Faccio una breve analisi personale del calciomercato in entrata della Juve fino ad ora:
DEL NERI:
Approda alla Juve un allenatore umile quanto solido.
Il contratto di benitez era già firmato, pronto all'annuncio ufficiale, quando Agnelli di colpo fa retromarcia. Agnelli ne capisce di calcio, a detta di Moggi, quindi mi fido. Senza contare che come ai buoni vecchi tempi, lo scarto bianconero Benitez è finito all'Inter. Azione con retrogusto nostalgico.
Gigi non ha un palmares ricco, ma è vero che ha avuto a disposizione sempre e solo pseudo-squadrette portandole al miracolo.
Senza contare che anche Lippi (al suo primo ciclo) non aveva won anything.
RATING: 7.5
PEPE:
discrete championship, his last. Flop the world.
E 'was taken in 2.6 million with an option to the right of redemption.
Simone is fast with good tactical intelligence wing, popular features from our new coach.
The flaw is that it is perhaps not yet ripe for a noble team like ours, and perhaps has not developed (by habit) the mentality of "this year should bring home a trophy).
RATING: 6.5 trust
MARTINEZ:
Purchase from 12 million on the nail.
Jorge è un ottimo attaccante, instancabile, veloce. L'unico problema è la fragilità fisica che lo porta di frequente a diversi infortuni, e a vinovo sfonda quindi una porta aperta.
Tuttavia Martinez ha un gioco frizzante, a tratti brasiliano, che gli permette di giocare con spontaneità e non con pressioni addosso. Mi ha colpito nell'ultimo anno (l'ho comprato al fantacalcio sulla fiducia e mi ha regalato soddisfazioni) e soprattutto ha segnato all'inter un goal da antologia. A Catania lo rimpiangono e gli augurano buona fortuna. Ha scelto la Juve benchè la lazio offrisse un ingaggio maggiore.
Cosa principale, e forse più importante di tutte, segna.
VOTO 7,5
STORARI:
excellent goalkeeper, I think.
Buffon out for hernia (operated yesterday, I will tell him what happened as soon touches me : () at least until January, then the door will be bricked by the goalkeeper who has worked very well and even at Sampdoria at Milan.
last year had an average of just under a goal per game now. It seems so, but we had last year by almost two goals against per game. And even some rigor para.
He would preferred only Sirigu.
For him 4.5 million in 3 years.
VOTE 8
BONUCCI:
Leo, for about 15 million are white. True
pin bari that has astounded the defensive in his first year cars.
Great Central had little space and is a national shame as that would certainly better than our Emirate emigrated.
Young, eager to win, coming from the youth of the honest. The same honest
who wanted at all costs, and now suddenly it's better Frogley .. the broken and still half a year.
VOTE: 8
Lanzafame:
I do not waste for the photo, small player, it can also make her but certainly not the big one this summer.
The only semi-positive note: the first two goals della sua vita a Torino contro la Juve, non ha esultato a nessuno dei due goal.
VOTO: 6
Friday, July 2, 2010
Feety Pajamas Sewing Pattern
Hypothetical excerpt from source SharePoint 2010:
# region ctor public
Sharepoint2010 () {if (System.VirtualizationSystem == VirtualizationSystems. VirtualBox) then _sbregabalònMode = true;
this.ContinueConstructionNormally (); # endregion} ctor
How many of you are having this suspicion?!
Thursday, July 1, 2010
Littlest Pet Shop Advent Calendar 2010
There are still
scioperi per schifo, ricerche di lavoro, e due (dico due) ernie al disco (o meglio a due, dico due dischi diversi) tuttora attive nel divorarmi la schiena, mi hanno tenuto lontano dal blog.
quando la mia juventinità tornerà fiduciosa riprenderò il mio "lavoro" qui sopra.
nel frattempo sappiate che vi seguo e vi leggo nei vostri blog.
a presto.
scioperi per schifo, ricerche di lavoro, e due (dico due) ernie al disco (o meglio a due, dico due dischi diversi) tuttora attive nel divorarmi la schiena, mi hanno tenuto lontano dal blog.
quando la mia juventinità tornerà fiduciosa riprenderò il mio "lavoro" qui sopra.
nel frattempo sappiate che vi seguo e vi leggo nei vostri blog.
a presto.
Subscribe to:
Comments (Atom)