Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Train Carriage Game Solutions

Name: Anonymous 2012-08-26 2:11

I'm looking to program a function that can check if you can "make 10" from some 4 digit number (0000 to 9999).

The function should use these rules when performing the check:
https://www.facebook.com/pages/Train-Carriage-Game/108348062559174?sk=info

Does /prog/ know if there's a simple way to perform such a check short of checking every combination individually? I obviously don't want to be writing the following:


boolean makesTen (int a, int b, int c, int d) {
    if (a + b + c + d == 10) {
        return true;
    } else if (-a + b + c + d == 10) {
        return true;
    } else if (a - b + c + d == 10) {
        return true;
    }
    ...
    ...
    } else {
        return false;
    }
}

Name: Anonymous 2012-08-28 16:56

00 isn't undefined. It's not 0 either. It's 1.

Name: Anonymous 2012-08-28 22:37

>>41

let p(t) = (0,t), with x(t) = 0, y(t) = t

lim t->0 x^y
= lim t->0 (0)^(t)
= lim t->0 0
= 0

let p(t) = (t,0), with x(t) = t, y(t) = 0

lim t->0 x^y
= lim t->0 (t)^(0)
= lim t->0 1
= 1

Name: Anonymous 2012-08-29 5:12

ЕСЛИ ТЫ НЕ ГОЛУБОЙ
НАРИСУЙ ВАГОН ДРУГОЙ


   ___________~~.____~~._____
  |  ___   ___    ___   ___  |
 ш| | | | |---|  |---| | | | |шш
 Н| | | | |___|  |___| | | | |НН
 м| |_|_| москва-адлер |_|_| |мм
  |_______|__________________|
Э==/ \ц/ \Т__Г       / \ц/ \==Е
   \_/ \_/           \_/ \_/

Name: Eduardo 2012-08-29 13:39

>>39 here
I realised I was making a mistake in evaluating expressions of the form:

-a^b


I was evaluating it as

(-a)^b

instead of

-(a^b)


The latter method allows me to take advantage of the way a carriage number (and it's sign -- +ve or -ve) is permuted, because

(b mod 2)==2

will always be positive.

I now think 9161 of 10000 carrage numbers from 0000 to 9999 make 10. Although (this time) I'm highly confident in my answer, I'd like someone else to confirm. The reason I'm confident in my answer is because the answers in the "cheat sheet" (http://tinyurl.com/everyfuckingsolution) seem reasonable. I also checked that the same 9161 carriage numbers make -10, though this could just mean I'm making the same mistake twice. (If a carriage number can make n, it can also make -n, right?)

Another thing. I was able to check (and show answers to) all 10000 carriage numbers in 4 minutes and a half on an stock i7 950. Can anybody check more than 37 solutions per second?

Name: >>36 2012-08-29 17:53

>>44
Are you just going to ignore my post entirely?

(Also, if you ended up defining 0^0 = 1 your results are still wrong. Either way... you should post a list of "unsolved" numbers.)

Name: Anonymous 2012-08-29 22:11

>>45
I don't understand.

I ended up changing it so that 0^0 was undefined. The cheat sheet does does contain unsolved games with the solution written "No solution." Unless you wanted me to post a list of numbers separately...

Name: Anonymous 2012-08-29 23:48

Am I being trolled? This is extremely easy.


#include <stdio.h>
#include <stdlib.h>

int main(void) {
  char buff[5];
  int n[4], i, num;
 
  int a, b, c, d;
 
  while(1) {
    fgets(buff, 5, stdin);
    buff[4] = '\0';
    if(!(num = atoi(buff))) {
      puts("NaN");
      continue;
    }
   
    num*=10;
    for(i = 0; i < 4; i++)
      n[i] = ((num/=10) % 10);
   
    for(a = -1; a <= 1; a += 2)
      for(b = -1; b <= 1; b += 2)
        for(c = -1; c <= 1; c += 2)
          for(d = -1; d <= 1; d += 2)
            if(a*n[0] + b*n[1] + c*n[2] + d*n[3] == 10) {
              puts("True");
              return(0);
            }
           
    puts("Nope");
  }
 
  return(1);
}


Also, to the person who suggested using recursion. Learn how to program.

Name: Anonymous 2012-08-30 0:07

>>47
Great! Now figure out how to include the other operators allowed in the train game (*, / and ^).

Name: Anonymous 2012-08-30 0:13

>>48
Would only be slightly more difficult. I didn't check out the rules because who doesn't have facebook blocked?

Name: Anonymous 2012-08-30 0:30

>>49
the forced partitioning into sums and products. thread made into an abstract syntax tree.

Name: Anonymous 2012-08-30 1:32

>>47
0 is not a number?

Name: Anonymous 2012-08-30 3:04

>>49
You don't need an account to view OP's link.

If you blocked Facebook in you hosts file or something, well then that's a pretty tin foil hat you have there.

Name: Anonymous 2012-08-30 3:05

>>52
fuck you faggot shit

Name: >>36 2012-08-30 7:34

>>46
Well, rule 6 on the Facebook page says you can use multiple digit base numbers, i.e., 0054 has (50-40) as a solution. (It appears I was looking at an old cached version of your answer sheet, so I hadn't noticed you're not using 0^0 anymore; my bad.)

Name: Anonymous 2012-08-30 7:34

If you blocked Facebook in you hosts file
Everyone needs to do this, in all honesty, if people weren't stupid then they would

Name: Anonymous 2012-08-30 7:59

>>54
rule 6
I don't like that rule. I suppose it shouldn't be too hard to solve though.

Name: Anonymous 2012-08-30 14:13

>>52
Enjoy your anal rape

Name: Anonymous 2012-08-30 23:56

>>57
Enjoy your anal. Only queers go to the trouble of blocking Facebook.

Name: Anonymous 2012-08-31 10:37

⑁㘁灑捗怶儇匶∆茅劂眆匣瑲ቢ鈵⦇倥㖈銔ᔹ㜗ᆖ碀ᔠ⍡耉衦Գᝀ蝘ᤁ瑦Ⅱ鍤蕖嚉梃肒‰饴ऩ䚑卥睦顙䑤艁皅䄩錆栐硈䅤蒗W❐㔁〘褀኉ᘒГᄳѠ隄協榆䀉堓啰و㕀㐀啀艀晥邐斗琧֓ȗ莆♆摒䤢⡉坃鑰ॐ鄸└䐴啰虨襓␈̈᥶ᅔ儕䀒ࡴ阥獤祴兩疈炗䌓園⍧栲村疐Α墙鑨椈㢔愇ᜰ蠶␴逄ᅓ愩ၥ㢀枃扙ࡇ䚗镨≅儀㍅桱獆၆☹☲搢偳㘳☹㥡ᙅᢃ晣剄䁗❁ᢑ猦㘸ė按䜙销椸葥䡢ऐޙኁ╓瀂吤ប鈂㍆留圁㦀桤ɂ偠ও䁇隀⁶㢐ْ鎗癉鉥љٸ╵鍧奢掅㙁㝐倀睧㌰虗ࡕ⒆瑵眄❑杘ぐ䄄㝒℃ᝣ᥆捗⑰┲ゔᔢ硤攘㡖ѹ怇脥栖䄹ԇ鞐✶造㔀䄆≶♀鉂妁š䊙Ȃᄲ蒈ݵᄄ奦她䅕慳ी朵荇茖䖙ᕗ锥㈱莒斘␳衁酇愑ᝒ頂碑褕鉔晶ᑉ䁔᜘ㄅₓ椰閑礥葅㚗≁ܘ鐆堠∴㌩ሠ留睸ថ牷蕹鍡䢈倐☣假ĸ衷肑遡遶猢♰ࡒԔ

Name: Anonymous 2012-08-31 10:40

㦃┘遉蒈┙鑷癁错禕鑉㞓㚗䌴⢒⠉蔑酷ተၨ嚅遅隑㑈噦ၣ鄳䔕顓㐸ぁ杢礃䔷    當䠤饖螗⌨ऑ㦗ለ梗莘匕顠撒鞉ն砶䁇虀褠攠硱㐷猣陇ኔ㢘祙倅щ㌁➂䁨塱䠔㜕ቃ猧☸ᜱ⁗腀ᆔ枖塒㔱萣㢗ؐ萇ħ顤霱偉挕锑㍉炗蠦塳獂႗ᄹ梗㐨䁠䉇ल蚆眃剁䡀撖噂㝤垅ㄤ䄃切≆圥吶᥁ࠂń腔酇蒑㘳䐰㕀瘥䐇ܩ㥧㙁ᔄ᠉⦄荗䀙䠓晴腩䈣焙灷刲㊆㠐↉列甗Ł逐≈न䄒榅蔓⡦静ΐᤢ捶㥇獢搳匘⥥吵襸̗╧圣⊅䆓ቢͦ塠兒ᅨ蘃性炀Փ䅱蒀ᄖ㆗皂朤噩㡐̴螈⥅★ކ喂癶襦♣吇⒕፥䘦ᔰа夑❇瀧䠉䎘ሖ螐ʑ䜈⌥善禐牠昄灱蘷㍳䍙灆袗嘓鍷夈㒁琀聣㦖ᑃ茑匄䠇㈥煑⦑ॅ圲吥瀡膓蠥䕹䤁ঁጆ㡘恈䒗逥锑楣琡ᑖ摓煃ࡘ㉀楇ᐗ℉厉ᄀ၉ڂᡗ㊂坲蒀ᙵև⑖ᅩ᝔愠蘐坩ᤦ㌆ƒ钓琐銘鑡⁤坅舴禄ᡇ砧脂䀰焥她灷灂霕蔕椷

Name: Anonymous 2012-08-31 10:42

㕅䅆阃ܶ慧ᒃㄤ畳虢奠③牂ᙕ㊒頔栣㍣鐐䅶䢖防⍵男萴镧噑ኄ䢗㝔、䦆㝨匷脸䢁鄅䞃–㍅馒噳鐧所䙕葆閇ᜲ䦁塑瞒֔咀餆ȹ㈁全嘖ဧ朠᥵⒐㘑䙒吲呥䞆㦘蜘梗؇ፄ瀔䙐ሀ㘁㜁㤹畃ㅢ㐂爀倨⠥䀓㌢蕲舕䉵蘓蘲砨⊃暒ၕ剈⡄㒄䌂⎓ᜧ֖ሂ№ㅳ饆⤨慴Đ䖁噢硁覂ޘ鈓㜲㈕䙤㜃夘ॖݦ圂፤иᐄ٨ᙘ䁂≑ࠢ㊘⊆ͳ爸㞁ड昖硹ᅸ⤈璄♑⒆鐒䒄ጓ⢙ٓէ敕術䀰ℴ馓萉閆莀印攰㘲㐗⚗荁㜘昵栳噥ʄ鑆ቖঈ舀ᙈ〘ᖀ蘦╅蒘酠椠Ȕ㤆ޓ呠㑐ᐄ晦聗䌩䙙衸楩〙᝹ᝃ銔鍥ၨ備葷᥅䁂ᑅ㥙㄃ↄ䥅ㅂ銗㡥搗衒敉瀠ᘐ托䐅呵❸唣ᘣ鉔ႆѨ畦啙鑑㔩楲∳ᜈ卂㉂嚙ॲ㤳ѵ襂㠒ᔆ鐂栓ΐ䡘榆需顉Ŵ䐠㦂儈灴剙〲㈨夐慘ᝥ耤▉⚉↕梅⡙⌂牅砘虄逩ㄱ㎒杶瑳爙蔑ᒕ〡㑸頇঒䍡虶፨㐐鈖䀙蠃䡡銇蔡畃႔ⅰ碀⍸ፗ☲陗備

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List