Re: 10 or more phones order
On Mon, Apr 28, 2008 at 11:45 PM, Federico Lorenzi <[EMAIL PROTECTED]> wrote: > Haha, one of the bests laughs I've had on here! Although I'm pretty > sure it violates PEP 346356 which clearly states that thou should not > use exec and base64 :) > If you think that python one-liner without base64 is better, here it is: (lambda f=(lambda n, v: globals().update({n: v})): f("set", f))() or set("wr", lambda v: __import__("sys").stdout.write(str(v).strip()+"\n")) or set("phone_count", 42) or wr("Please order %s" % ", ".join(["BOX" for _i in xrange(phone_count // 10)] + ["SINGLE" for _i in xrange(phone_count % 10)])) Have a nice day. ;) ___ Openmoko community mailing list community@lists.openmoko.org http://lists.openmoko.org/mailman/listinfo/community
Re: 10 or more phones order
Haha, one of the bests laughs I've had on here! Although I'm pretty sure it violates PEP 346356 which clearly states that thou should not use exec and base64 :) Cheers, Federico On 4/28/08, Ilja O. <[EMAIL PROTECTED]> wrote: > > > > So why's it not in Perl then, > > You could do all that in a simple one-liner... > > > > ;o) > > > > > > I don't know Perl :( > But I could try to write on z/OS HLASM. Or Erlang... > > Btw, it could be simple one-liner in Python too. > Like this: > phone_count = 42 > _orders = ["BOX" for _i in xrange(phone_count // 10)] + ["SINGLE" > for _i in xrange(phone_count % 10)] > print("Please, order %s" % ", ".join(_orders)) > > Or if you want REALLY python one-liner: > > exec("eJwryMjPS41Pzi/NK1GwVTAx4orPL0pJLSoGcqKVnPwjlBTS8osU4jMVMvMUKooS89JTNQqQtOjrKxgaaMYqaANVB3v6ufu4EtCgClbPVVCUmVeioRSQk5pYnKqjALZTQbVYCSivpKOgpJeVn5mnAXWKpiYAGp0z4g==".decode("base64").decode("zip")) > > ___ > Openmoko community mailing list > community@lists.openmoko.org > http://lists.openmoko.org/mailman/listinfo/community > ___ Openmoko community mailing list community@lists.openmoko.org http://lists.openmoko.org/mailman/listinfo/community
Re: 10 or more phones order
On 4/28/08, Flemming Richter Mikkelsen <[EMAIL PROTECTED]> wrote: > All the code can be written with standard cut (the Unix command). btw., awk is more easy than cut :) -- Please don't send me Word or PowerPoint attachments. See http://www.gnu.org/philosophy/no-word-attachments.html Join the FSF as an Associate Member at: http://www.fsf.org/register_form?referrer=5774> Free your mind - Open(moko) your phone ___ Openmoko community mailing list community@lists.openmoko.org http://lists.openmoko.org/mailman/listinfo/community
Re: 10 or more phones order
On 4/28/08, Pietro m0nt0 Montorfano <[EMAIL PROTECTED]> wrote: > Ilja O. ha scritto: > > > > > So why's it not in Perl then, > > > You could do all that in a simple one-liner... > > > > > > ;o) > > > > > > > > > > > > > I don't know Perl :( > > But I could try to write on z/OS HLASM. Or Erlang... > > > > Btw, it could be simple one-liner in Python too. > > Like this: > > phone_count = 42 > > _orders = ["BOX" for _i in xrange(phone_count // 10)] + ["SINGLE" > > for _i in xrange(phone_count % 10)] > > print("Please, order %s" % ", ".join(_orders)) > > > > Or if you want REALLY python one-liner: > > > exec("eJwryMjPS41Pzi/NK1GwVTAx4orPL0pJLSoGcqKVnPwjlBTS8osU4jMVMvMUKooS89JTNQqQtOjrKxgaaMYqaANVB3v6ufu4EtCgClbPVVCUmVeioRSQk5pYnKqjALZTQbVYCSivpKOgpJeVn5mnAXWKpiYAGp0z4g==".decode("base64").decode("zip")) > > > > > > Oh My God > > It was just the moment, it was because it's passed some time since i stopped > using C at work i think, it could be python, perl, bash, php, c, c++, basic, > javascript, ASM, also java (i don't like it),. :D > > It was the moment :D All the code can be written with standard cut (the Unix command). But here is the C code: /* input: the number of Freerunners */ /* returns the total netto Openmoko price for Freerunners */ unsigned long get_price(unsigned short no) { unsigned long price=0; while (no%10) { price += 399; no--; } while (no) { price += 9*399; no -= 10; } return price; } -- Please don't send me Word or PowerPoint attachments. See http://www.gnu.org/philosophy/no-word-attachments.html Join the FSF as an Associate Member at: http://www.fsf.org/register_form?referrer=5774> Free your mind - Open(moko) your phone ___ Openmoko community mailing list community@lists.openmoko.org http://lists.openmoko.org/mailman/listinfo/community
Re: 10 or more phones order
Ilja O. ha scritto: So why's it not in Perl then, You could do all that in a simple one-liner... ;o) I don't know Perl :( But I could try to write on z/OS HLASM. Or Erlang... Btw, it could be simple one-liner in Python too. Like this: phone_count = 42 _orders = ["BOX" for _i in xrange(phone_count // 10)] + ["SINGLE" for _i in xrange(phone_count % 10)] print("Please, order %s" % ", ".join(_orders)) Or if you want REALLY python one-liner: exec("eJwryMjPS41Pzi/NK1GwVTAx4orPL0pJLSoGcqKVnPwjlBTS8osU4jMVMvMUKooS89JTNQqQtOjrKxgaaMYqaANVB3v6ufu4EtCgClbPVVCUmVeioRSQk5pYnKqjALZTQbVYCSivpKOgpJeVn5mnAXWKpiYAGp0z4g==".decode("base64").decode("zip")) Oh My God It was just the moment, it was because it's passed some time since i stopped using C at work i think, it could be python, perl, bash, php, c, c++, basic, javascript, ASM, also java (i don't like it),. :D It was the moment :D Cya! Pietro ___ Openmoko community mailing list community@lists.openmoko.org http://lists.openmoko.org/mailman/listinfo/community
Re: 10 or more phones order
> > So why's it not in Perl then, > You could do all that in a simple one-liner... > > ;o) > > I don't know Perl :( But I could try to write on z/OS HLASM. Or Erlang... Btw, it could be simple one-liner in Python too. Like this: phone_count = 42 _orders = ["BOX" for _i in xrange(phone_count // 10)] + ["SINGLE" for _i in xrange(phone_count % 10)] print("Please, order %s" % ", ".join(_orders)) Or if you want REALLY python one-liner: exec("eJwryMjPS41Pzi/NK1GwVTAx4orPL0pJLSoGcqKVnPwjlBTS8osU4jMVMvMUKooS89JTNQqQtOjrKxgaaMYqaANVB3v6ufu4EtCgClbPVVCUmVeioRSQk5pYnKqjALZTQbVYCSivpKOgpJeVn5mnAXWKpiYAGp0z4g==".decode("base64").decode("zip")) ___ Openmoko community mailing list community@lists.openmoko.org http://lists.openmoko.org/mailman/listinfo/community
Re: 10 or more phones order
On Mon, 28 Apr 2008 11:28:56 +0200, Ilja O. <[EMAIL PROTECTED]> wrote: On Mon, Apr 28, 2008 at 12:12 PM, Federico Lorenzi <[EMAIL PROTECTED]> wrote: And why is it not in Python? It would be too easy to read. So why's it not in Perl then, You could do all that in a simple one-liner... ;o) Richard ___ Openmoko community mailing list community@lists.openmoko.org http://lists.openmoko.org/mailman/listinfo/community
Re: 10 or more phones order
On Mon, Apr 28, 2008 at 12:12 PM, Federico Lorenzi <[EMAIL PROTECTED]> wrote: > And why is it not in Python? > > It would be too easy to read. ___ Openmoko community mailing list community@lists.openmoko.org http://lists.openmoko.org/mailman/listinfo/community
Re: 10 or more phones order
And why is it not in Python? On 4/28/08, Ilja O. <[EMAIL PROTECTED]> wrote: > > > > I just can't leave it like that. :-) > > > > if (phones_ordered % 10 * PRICE_1 > PRICE_10_PACK) > > phones_ordered += 10 - phones_ordered % 10; > > Is this really necessary? > what this code is for? > And where are comments? :) > > ___ > Openmoko community mailing list > community@lists.openmoko.org > http://lists.openmoko.org/mailman/listinfo/community > ___ Openmoko community mailing list community@lists.openmoko.org http://lists.openmoko.org/mailman/listinfo/community
Re: 10 or more phones order
> > I just can't leave it like that. :-) > > if (phones_ordered % 10 * PRICE_1 > PRICE_10_PACK) > phones_ordered += 10 - phones_ordered % 10; Is this really necessary? what this code is for? And where are comments? :) ___ Openmoko community mailing list community@lists.openmoko.org http://lists.openmoko.org/mailman/listinfo/community
Re: 10 or more phones order
On Mon, 28 Apr 2008 10:20:46 +0200, ian douglas <[EMAIL PROTECTED]> wrote: Well, may be that i missed the answer but someone asked if the discount and the extra stuff are applied only to the 10 pack or it could also be a 12 pack? So to let you understand the condition is: if (phones_ordered == 10) do_the_10_pack_trick(); More like: if (phones_ordered && phones_ordered % 10 == 0) do_the_10_pack_trick(); I just can't leave it like that. :-) if (phones_ordered % 10 * PRICE_1 > PRICE_10_PACK) phones_ordered += 10 - phones_ordered % 10; for (; phones_ordered >= 10; phones_ordered -= 10) do_the_10_pack_trick(); for (; phones_ordered >= 1; phones_ordered--) no_tricks_just_order_1(); -- Alexey Feldgendler <[EMAIL PROTECTED]> [ICQ: 115226275] http://feldgendler.livejournal.com ___ Openmoko community mailing list community@lists.openmoko.org http://lists.openmoko.org/mailman/listinfo/community
Re: 10 or more phones order
Pietro "m0nt0" Montorfano wrote: Well, may be that i missed the answer but someone asked if the discount and the extra stuff are applied only to the 10 pack or it could also be a 12 pack? So to let you understand the condition is: if (phones_ordered == 10) do_the_10_pack_trick(); More like: if (phones_ordered && phones_ordered % 10 == 0) do_the_10_pack_trick(); Steve has already mentioned on the list that ordering 11 phones means getting a bulk discount on the 10-pack, but paying full price on the stray 11th phone. -id ___ Openmoko community mailing list community@lists.openmoko.org http://lists.openmoko.org/mailman/listinfo/community
Re: 10 or more phones order
On Mon, April 28, 2008 4:27 pm, Flyin_bbb8 wrote: > from my understanding its the first :p but don't know.. My understanding is that there will be two different things that you can buy. - a single phone. - a pack of 10 phones. You can buy multiples of each. If you like, you can be 10 lots of "a single phone". but this would be more expensive than 1 lot of "a pack of 10 phones". You cannot but "a pack of 12 phones". You would need either "a pack of 10 phones" plus 2 lots of "a single phone", or 2 lots of "a pack of 10 phones" (which would leave you with some spares). NeilBrown > > On Mon, Apr 28, 2008 at 9:13 AM, Pietro m0nt0 Montorfano > <[EMAIL PROTECTED]> > wrote: > >> Well, may be that i missed the answer but someone asked if the discount >> and the extra stuff are applied only to the 10 pack or it could also be >> a 12 >> pack? >> So to let you understand the condition is: >> >> if (phones_ordered == 10) >>do_the_10_pack_trick(); >> >> or it is something like: >> >> if (phones_ordered >= 10) >>do_the_10_pack_trick(); >> >> ? :D >> >> Cya >> >> Pietro >> >> ___ >> Openmoko community mailing list >> community@lists.openmoko.org >> http://lists.openmoko.org/mailman/listinfo/community >> > ___ > Openmoko community mailing list > community@lists.openmoko.org > http://lists.openmoko.org/mailman/listinfo/community > ___ Openmoko community mailing list community@lists.openmoko.org http://lists.openmoko.org/mailman/listinfo/community
Re: 10 or more phones order
from my understanding its the first :p but don't know.. On Mon, Apr 28, 2008 at 9:13 AM, Pietro m0nt0 Montorfano <[EMAIL PROTECTED]> wrote: > Well, may be that i missed the answer but someone asked if the discount > and the extra stuff are applied only to the 10 pack or it could also be a 12 > pack? > So to let you understand the condition is: > > if (phones_ordered == 10) >do_the_10_pack_trick(); > > or it is something like: > > if (phones_ordered >= 10) >do_the_10_pack_trick(); > > ? :D > > Cya > > Pietro > > ___ > Openmoko community mailing list > community@lists.openmoko.org > http://lists.openmoko.org/mailman/listinfo/community > ___ Openmoko community mailing list community@lists.openmoko.org http://lists.openmoko.org/mailman/listinfo/community
10 or more phones order
Well, may be that i missed the answer but someone asked if the discount and the extra stuff are applied only to the 10 pack or it could also be a 12 pack? So to let you understand the condition is: if (phones_ordered == 10) do_the_10_pack_trick(); or it is something like: if (phones_ordered >= 10) do_the_10_pack_trick(); ? :D Cya Pietro ___ Openmoko community mailing list community@lists.openmoko.org http://lists.openmoko.org/mailman/listinfo/community