Supporta il tuo Forum su Patreon!
 
  > Register  
  > Calendar  
  > Member List  
 
  > Support your Forum  
  > Today's Posts  
   

Go Back   netgamers.it > Tech & Tech > Developer's Zone

Reply
 
Thread Tools Rate Thread
Old 27th May 2007, 20:40   #16
.Z.
fork()
 
.Z.'s Avatar
 
Join Date: Jan 2002
Location: Bologna
Posts: 13,783
Su quel forum ci sono mostri

O semplicemente gente che ha studiato:

Phi (golden ratio) is the approximate ratio between
two consecutive terms in a Fibonacci sequence.
The ratio between consecutive even terms approaches
phi^3 (4.236068) because each 3rd term is even.
Use a calculator and round the results to the nearest
integer when calculating the next terms:

2,8,34,.. multiplying by 4.236068 each time: 144,610,
2584,10946,46368,196418 & 832040

The sum is 1089154

La sezione aurea me l'ha spiegata wikipedia ieri
Sta a vedere che è la volta buona che mi metto a studiare matematica sul serio.
__________________
Personally, I would never want to be a member of any group where you either have to wear a hat, or you can't wear a hat.

Last edited by .Z.; 27th May 2007 at 20:43.
.Z. is offline   Reply With Quote
Old 27th May 2007, 21:07   #17
Darklord
lupetto supremo
 
Darklord's Avatar
 
Join Date: Mar 1999
Location: Bari
Posts: 12,829
ma questo trip è venuto solo a me e te?
Aresio, gh3 & co....avete perso punti in nerdaggine!
__________________
Python-foo Black Belt
NGI Forum
» Tech & Tech » Developer's Zone
Darklord is offline   Reply With Quote
Old 27th May 2007, 23:57   #18
Aresio
Soft computer
 
Aresio's Avatar
 
Join Date: Feb 2000
Posts: 540
macché, è che in matematica son quello messo peggio quà dentro

insomma, vorrei, sbavo ma non posso.
__________________
Lode a Bacco, in saecula saeculorum.
Emergent
Aresio is offline   Reply With Quote
Old 28th May 2007, 11:43   #19
Doriän
~
 
Doriän's Avatar
 
Join Date: Jan 2006
Posts: 1,993
rosico
Doriän is offline   Reply With Quote
Old 28th May 2007, 12:09   #20
The Big
Armata Baccanale
 
The Big's Avatar
 
Join Date: Apr 2003
Location: /home/carlesso
Posts: 4,129
Quello dei palintromi fatto col rev mi ha dato soddisfazioni
__________________
The Big: the e.gmail filler Xperience
OK, so you're a Ph.D. Just don't touch anything.
Il mio sito, e il mio blog
The Big is offline   Reply With Quote
Old 28th May 2007, 17:34   #21
Darklord
lupetto supremo
 
Darklord's Avatar
 
Join Date: Mar 1999
Location: Bari
Posts: 12,829
Ecco una soluzione parziale al quesito 3, che ho dovuto scartare.
Dico parziale perchè l'algoritmo è il classico bruteforce poco efficiente, ed è castrato dal RecursionLimit di python (si può modificare, ma non mi va), che non permette di avere più di 1000 ricorsioni.

La posto perchè presenta varie sboronaggini come la doppia ricorsione con funzioni annidate e la restituzione in output di più valori con una singola return.
Python

Code:
def factorize(n,f=[]):
    def getPrime(i):
        q,r = divmod(n,i)
        if r: return getPrime(i+1)
        else: 
            f.append(i)
            return factorize(q,f)
    if n<>1:return getPrime(2),f
    else: return
    
if __name__ == '__main__':
   a,b = factorize(13195)
   print max(b)
__________________
Python-foo Black Belt
NGI Forum
» Tech & Tech » Developer's Zone

Last edited by Darklord; 28th May 2007 at 17:45.
Darklord is offline   Reply With Quote
Old 28th May 2007, 17:45   #22
The Big
Armata Baccanale
 
The Big's Avatar
 
Join Date: Apr 2003
Location: /home/carlesso
Posts: 4,129
O mio dio quanto mi sento stronzo

Quesito 19:
How many Sundays fell on the first of the month during the twentieth century (1 Jan 1901 to 31 Dec 2000)?
Code:
#!/bin/bash

COUNT=0
for i in $(seq 1901 2000) ; do
        for j in $(seq 12); do
                if [ $(cal $j $i | head -n3  | tail -n1 | grep 7 | wc -l) == "1" ] ; then
                        COUNT=$(( $COUNT + 1 ))
                fi
        done
done
echo There has been $COUNT mounth starting on Sunday :-\)
__________________
The Big: the e.gmail filler Xperience
OK, so you're a Ph.D. Just don't touch anything.
Il mio sito, e il mio blog
The Big is offline   Reply With Quote
Old 28th May 2007, 18:15   #23
.Z.
fork()
 
.Z.'s Avatar
 
Join Date: Jan 2002
Location: Bologna
Posts: 13,783


Per alcuni problemi bash è quasi un cheat.
__________________
Personally, I would never want to be a member of any group where you either have to wear a hat, or you can't wear a hat.
.Z. is offline   Reply With Quote
Old 28th May 2007, 19:13   #24
.Z.
fork()
 
.Z.'s Avatar
 
Join Date: Jan 2002
Location: Bologna
Posts: 13,783
Quote:
Originally Posted by The Big View Post
O mio dio quanto mi sento stronzo
E se non è stronza questa...

Code:
# ncal label for "Sunday" in your locale (Su, do, ...)
sunday=$(ncal | sed -n '$s/[ 0-9]//gp')

echo -n "Answer: "

# ncal outputs all the years from 1901 to 2000...
for i in $(seq 1901 2000) ; do
        ncal $i
done |
        # select only sundays...
        grep "^$sunday" |
        # verticalize output...
        tr -s [:space:] '\n' |
        # count ones.
        grep -c '^1$'
edit, sed al posto di tail e grep
Code:
< sunday=$(ncal | tail -n1 | grep -o '^\<[[:alpha:]]\{1,\}\>')
---
> sunday=$(ncal | sed -n '$s/[ 0-9]//gp')
__________________
Personally, I would never want to be a member of any group where you either have to wear a hat, or you can't wear a hat.

Last edited by .Z.; 28th May 2007 at 19:41.
.Z. is offline   Reply With Quote
Old 28th May 2007, 19:16   #25
Darklord
lupetto supremo
 
Darklord's Avatar
 
Join Date: Mar 1999
Location: Bari
Posts: 12,829
ma quanto rulla Begoner?
trova sempre degli algoritmi matematici super efficienti.
lo odio
__________________
Python-foo Black Belt
NGI Forum
» Tech & Tech » Developer's Zone
Darklord is offline   Reply With Quote
Old 29th May 2007, 17:48   #26
Darklord
lupetto supremo
 
Darklord's Avatar
 
Join Date: Mar 1999
Location: Bari
Posts: 12,829
Il problema 5 l'ho fatto al primo tentativo con carta e penna
__________________
Python-foo Black Belt
NGI Forum
» Tech & Tech » Developer's Zone
Darklord is offline   Reply With Quote
Old 29th May 2007, 19:17   #27
Darklord
lupetto supremo
 
Darklord's Avatar
 
Join Date: Mar 1999
Location: Bari
Posts: 12,829
soluzione python traccia 6...
volendo si fa tranqui con una sola riga:
Code:
sumOfTheSquares = lambda x:sum(map(lambda x:x**2, range(2,x+1)))+1
squareOfTheSum = lambda x:pow(sum(range(1,x+1)),2)
print squareOfTheSum(100)-sumOfTheSquares(100)
__________________
Python-foo Black Belt
NGI Forum
» Tech & Tech » Developer's Zone
Darklord is offline   Reply With Quote
Old 29th May 2007, 22:00   #28
.Z.
fork()
 
.Z.'s Avatar
 
Join Date: Jan 2002
Location: Bologna
Posts: 13,783
Qualcuno mi trovi il modo di selezionare l'i-esima cifra di un numero senza usare funzioni di libreria
__________________
Personally, I would never want to be a member of any group where you either have to wear a hat, or you can't wear a hat.
.Z. is offline   Reply With Quote
Old 29th May 2007, 22:12   #29
The Big
Armata Baccanale
 
The Big's Avatar
 
Join Date: Apr 2003
Location: /home/carlesso
Posts: 4,129
in che linugaggio?
__________________
The Big: the e.gmail filler Xperience
OK, so you're a Ph.D. Just don't touch anything.
Il mio sito, e il mio blog
The Big is offline   Reply With Quote
Old 29th May 2007, 22:38   #30
.Z.
fork()
 
.Z.'s Avatar
 
Join Date: Jan 2002
Location: Bologna
Posts: 13,783
In matematica

Vorrei trovare un metodo esclusivamente matematico (aritmetico? ) per trovare 4 se voglio la terza cifra più significativa (o la seconda meno significativa) di 1342.

La soluzione più intuitiva prevede divisioni per 10 e arrotondamenti con floor (), ma non volevo usare funzioni di libreria, volevo farmi la soluzione tutta da me

Altrimenti riduciamo il problema a implementare in modo aritmetico floor.
__________________
Personally, I would never want to be a member of any group where you either have to wear a hat, or you can't wear a hat.
.Z. is offline   Reply With Quote
Reply

Tags
euler, matematica

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 04:48.



Copyright 2017-2024 by netgamers.it