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

Pages: 1-

/prog/ Challenge: Dubs and Trips

Name: Anonymous 2018-05-24 3:25

Basically a meme variation of FizzBuzz, but not exactly the same.

Write a program that outputs numbers between 1 and 1000 (inclusively). This is like a text board thread.

If it's dubs, instead of the number, print dubs. If trips, print trips. For trips, do NOT also output dubs. Only one or the other. If it's dubs or trips, do not include the number.

Example output:
987
dubs
989
990
991
992
993
994
995
996
997
998
trips


Notice that for 990, it doesn't output dubs, because it only counts for the last digits. And 999 only says trips, not dubs (even though it's also dubs, technically).

Name: Anonymous 2018-05-24 4:37

the pattern makes it really easy

(10 dubs)
111
(10 dubs)
222
(10 dubs)
333
(10 dubs)
444
(10 dubs)
555
(10 dubs)
666
(10 dubs)
777
(10 dubs)
888
(10 dubs)
999
1000

Name: Anonymous 2018-05-24 7:00

how many times are we going to do the same 'fizzbuzz with dubs' challenge? anyway, here's FIOC2:

x=0;exec("x+=1;print x if(x%100%11 and x%100)else'dubs'if(x%111 and x%1000)else'trips';"*1000)

Name: Anonymous 2018-05-24 7:07

>>3
you're the tiger woods of obsolete python

Name: Anonymous 2018-05-24 7:19

>>4
thanks, but tbh those are pretty basic FIOC golfing tricks: string multiplication instead of loop often saves you a lot of characters, py2 instead of 3 saves you one byte on print (one space instead of two parens) and the rest is just one-char variables and whitespace removal

Name: Anonymous 2018-05-24 11:51

>>5
But I thought the whole point of python was the forced whitespace.

Name: Anonymous 2018-05-24 12:10

>>6
no, it's (one word) Forced Indentation Of Code. other whitespaces are not significant

Name: Anonymous 2018-05-24 13:17

Compile with :gcc -include "stdio.h" dubs.c
main(i){while(i<999)printf(i%10==i/10%10?i%10==i/100?"trips\n":"dubs\n":"%d\n",++i);}

Name: Anonymous 2018-05-24 13:30

>>8
Some explanation to what is going on for those who don't know C:
1.main defaults to int
2.(i) i defaults to int too, and renames first argument (int argc)
3.argc is 1 by default if no arguments are given.(first argument argv[0] is program name)
4.printf chooses one of three strings, "trips\n":"dubs\n":"%d\n", first two ignore the number (++i) since they lack the decimal output specifier "%d" which is used only if no conditions are met.
5.the condition ternary is left as exercise to the reader.

Name: Anonymous 2018-05-24 13:46

>>8
Compile with :gcc -include "stdio.h"
This extra option counts against your byte score my friend.

Name: Anonymous 2018-05-24 14:15

>>8,9
nice, but shouldn't you add i=1; so that people won't break your're are program by providing a fuckton of args?

Name: Anonymous 2018-05-24 14:30

>>10,11
Pythonista refuses to believe C can outgolf python, so he snakely tries to gain advantage.

Name: Anonymous 2018-05-24 22:19

>>8,9
I thought you had left for your forums forever, FrozenAnus.

Name: Anonymous 2018-05-24 22:49

puts ("1".."1000").map{|s|s=~/(\d)\1\1$/?'trips':s=~/(\d)\1$/?'dubs':s}

SLOW AS FUCK

Name: Anonymous 2018-05-24 23:04

omg optimized


puts ("1".."1000").map{|s|s=~/(.)\1\1$/?'trips':s=~/(.)\1$/?'dubs':s}

Name: Anonymous 2018-05-24 23:08

And bash:

seq 1 1000 | sed -E 's/.*(.)\1\1$/trips/g;s/.*(.)\1$/dubs/g'

Name: Anonymous 2018-05-24 23:09

Oops, forgot to optimize my white space:

seq 1 1000|sed -E 's/.*(.)\1\1$/trips/g;s/.*(.)\1$/dubs/g'

Name: Anonymous 2018-05-24 23:11

Omg optimized my
seq

seq 1000|sed -E 's/.*(.)\1\1$/trips/g;s/.*(.)\1$/dubs/g'

Name: Anonymous 2018-05-25 5:02

>>13
Not really, i mainly post on HackerNews.

Name: Anonymous 2018-05-25 6:27

>>19
do hackerjews #include <void.h>?

Name: Anonymous 2018-05-25 7:04

Write a program that outputs numbers between 1 and 1000 (inclusively). This is like a text board thread.
If it's dubs, instead of the number, print dubs. If trips, print trips. For trips, do NOT also output dubs. Only one or the other. If it's dubs or trips, do not include the number.

Name: Anonymous 2018-05-25 7:06

this post should be recognized as dubs by your're are program

Name: Anonymous 2018-05-25 14:22

>>22
yourDubs.recognized = true;

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