Hacker Newsnew | past | comments | ask | show | jobs | submit | JayXon's commentslogin

The current world record for the shortest C program that prints 12 Days of Christmas lyrics is 431 bytes: https://code.golf/12-days-of-christmas#c


Well that post just cost me a couple of hours.

And still 136 bytes off 431:

  #define p printf 
  int main(){const char *g[]={"A Partridge in a Pear 
  Tree.\n","Two Turtle Doves, and","Three French Hens,","Four 
  Calling Birds,","Five Gold Rings,"," Geese-a-Lay"," Swans- 
  a-Swimm","t Maids-a-Milk","e Ladies Danc"," Lords-a-Leap"," 
  Pipers Pip","Twelve Drummers Drumm"};
  const char *d[{"First","Second","Third","Four","Fif","Six","Seven","Eigh","Nin","Ten","Eleven","Twelf"};for(int i=0,j;i<12;i++){p("On 
  the %s%s day of Christmas\nMy true love sent to 
  me\n",d[i],i>2?("th"):"");
  for(j=i;j>=0;j--){p("%s%s%s\n",j>4&&j<11? 
  d[j]:"",g[j],j>4?"ing,":"");}}}


You can shave 25 more by using printf as is, removing "const", removing spaces between char and *, and removing parenthesis around "th".


Are those consts really necessary? There are also a few character missing after char *d.


> Are those consts really necessary?

Technically yes, initializing a plain char * from a const char * (from array decay) is a constraint violation (an error the standard requires the compiler to detect and complain about) even in C89. Many compilers will let you off with a warning though.


which characters are missing?


"]=" after "*d["


It's not necessary in C.


   const char *d[{"First","Second",...,"Twelf"};
is not a valid C unconditionally.


You should tell my compiler.


To be honest, I understand code.golf's premise, but still, code being public (maybe optionally?) would be nice.


I agree. Stack Exchange's Code Golf has public source, but the best there is 644 bytes: https://codegolf.stackexchange.com/a/4198


Is it broken for anyone else the code prints hello world and then some numbers


The leaderboard is public but the actual code is private, that hello world is just an example c program.


The prompt is a quote from a book, and it mentions "opened his beak and sang a loud, lovely trill", and the Imagen 2 robin does exactly that, but both SD ignored it completely, and SD1.5 isn't even on top of the wall.


generate_204 is used to check if a network has internet connection or need to login at captive portal, not sure about Fuchsia but on Android if you don't want to use google server for that, you can disable the feature or change it to use a different url https://android.stackexchange.com/questions/186993/captive-p...

Apple and Microsoft both have something similar but with their own website, and AFAIK there's no way to change the url on iOS.


What I meant was remove the code to make these automatic connections to Google servers from the OS source, re-compile and re-install.

That is what I look for in "open source". If I cannot edit, re-compile and re-install, much of the value to me of "open source" is lost.


But this is not always a fair label to apply. If I release a device running Android that prevents you from using your own Android, that's a problem with me and the device I released, not with Android. This seems to be conflating hardware and software -- which is understandable in the context of operating systems -- but we should be clear about the cause of the problem, which has nothing to do with the openness of the code.


According to https://twitter.com/syndk8/status/1157930276208750593

> Powered by is a footprint that black hats/hackers and spammers use to find targets.

So maybe Google isn't being slow, it's just sleeping intentionally to avoid abuse?


I think they were talking about wikimedia.org also being blocked due to CNAME to wikipedia.org which is now blocked, and they fixed it by CNAME to dyna.wikimedia.org instead, but wikipedia.org is still blocked: https://en.greatfire.org/https/en.wikipedia.org


If you care about camera so much, especially in low-light, you probably want to upgrade to a Pixel, the night sight feature is like magic.


I personally prefer to stay in Apple's ecosystem, but features like that are certainly interesting and speak to the type of camera improvements I was talking about in my comment.


Guess "always" was the wrong word, then.


I have an iMac, iPad, MacBook Pro, Apple Watch, AirPods...and so on. My friends and family also have Apple devices in their homes. My workplace is 100% Mac.

There's no chance I'm getting anything but an iPhone, for those and a number of other reasons.

With that being said, there are significant improvements year over year in the camera hardware used across the industry regardless of manufacturer. There's also really innovative stuff going on in camera software and computational photography from both Google and Apple among others (shoutout to Halide Camera).

I'm not going to swap out my entire phone operating system and integrated workflow for a single software-feature like Night Sight (even though I think it's very cool).

I was just making a statement about how smartphone cameras (as a category) will continue to get more impressive through a combination of software and hardware. The step function improvements in the camera experience alone are enough for me to consider upgrading even if the rest of the experience is only marginally better. The point being that even as someone with more expensive cameras and lenses, the camera on a phone is still extraordinarily important to people like me because it's the camera we end up having with us all the time.

I get that you really want to turn this into an Apple vs Android thing, but I'm going to play that game with you.


And that's why Apple prices are only going to keep rising, lots of people are locked in on their own choice.

If I were you I'd start planning how to move to the side where competition is actually a thing, before you're paying 4x or 5x for the same thing.


The price increases are 100% fine by me and do not impact me as a customer.

The value of the ecosystem working reliably together is worth the premium to me (in addition to things like reliable updates, good privacy models, and a focus on customer service, among other things).

Apple have an incredibly opinionated view of computing, for sure - but it's one that I prefer even at increased cost.

With that being said, I would like to keep the focus of this conversation on camera technology across the industry. Apple or no Apple, the cool stuff going on in computational photography excite me as a photographer.


Not the Grandparent, but I'd point out you turned it into an Apple vs everything else thing =]


If you are interested in this sort of thing, make sure to checkout Funky File Formats by Ange Albertini https://events.ccc.de/congress/2014/Fahrplan/events/5930.htm...


Something else interesting from a few years ago: a compression algorithm that's bijective. http://www3.sympatico.ca/mt0000/bicom/bicom.html

It's similar in the sense that there's more than one possible operation on any file (decompress it, or compress it), and different in that the file type doesn't change.


> This article reminds me of the time when the iOS alarm clock app had a bug that caused the alarm to go off one hour later on some random Sunday and it made headlines in all the tech press.

Android alarm going off one hour earlier in Brazil also got some press attention today. https://androidcommunity.com/brazils-dst-change-inadvertentl...


Nobody uses iMessage in China because SMS is expensive. iCloud data in China is stored in a datacenter in China where the Chinese government can access any data any time they want with no warrant whatsoever.


iMessage isn't SMS so I don't understand your first sentence. That's like saying "Nobody sends email because postal stamps are expensive".

As for the second sentence, iMessage isn't iCloud. And even if the iMessage data is stored in the same data center (which I have no idea), it's end-to-end encrypted so that doesn't help China.


I meant that because iMessage fallback to SMS and you don't know if sending an iMessage to someone will go through iMessage or SMS which might cost you money, that's why nobody uses iMessage.

iMessage isn't iCloud, but iMessages are stored in iCloud, Apple also stores iCloud encryption keys in China. See https://techcrunch.com/2018/02/25/apple-moves-icloud-encrypt...


it’s pretty easy to disable the fallback


If Apple needs to comply with China's demands, do you think that Apple would refuse to break encryption if China requested it?


Yes. I think Apple would disable iMessage in China entirely before breaking its encryption.


I disagree. But say the option wasn't to disable imessage, but rather break the encryption or stop selling in China? Or stop using your own encrypted icloud storage and use one run by China or stop selling in China?

To buttress your belief, is there any circumstance where they didn't cave to requests from the Chinese government? Or anywhere where they publicly disagreed at least? Honest question as I'm unsure if it has ever happened.


China can't mandate that Apple run an unencrypted messaging system in China. They could demand that Apple not run an encrypted one, but it would be complete nonsense to say "you must operate a message network or you can't sell phones!"

> To buttress your belief, is there any circumstance where they didn't cave to requests from the Chinese government?

I don't see how I could have an answer to that question, because Apple doesn't publicize the times that China asks them to do something and they say no. I would certainly imagine that China has probably asked them to break the encryption on iMessage.


shameless plug: you can throw a windows pe file (exe, dll, etc.) at leanify and it will remove all the garbage in pngs in that pe file (even those embedded pngs in high res ico file in pe file), and it will also optimize png compression with zopfli. But don't use it on windows system files because modifying those pe files will definitely break the digital signature.


Author here -- Very neat, saves writing another tool!


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: