[a / b / c / d / e / f / g / gif / h / hr / k / m / o / p / s / t / u / v / vg / vm / vmg / vr / vrpg / vst / w / wg] [i / ic] [r9k / s4s / vip] [cm / hm / lgbt / y] [3 / aco / adv / an / bant / biz / cgl / ck / co / diy / fa / fit / gd / hc / his / int / jp / lit / mlp / mu / n / news / out / po / pol / pw / qst / sci / soc / sp / tg / toy / trv / tv / vp / vt / wsg / wsr / x / xs] [Settings] [Search] [Mobile] [Home]
Board
▼ Settings Mobile Home
/g/ - Technology

Name
Options
Comment
Verification
4chan Pass users can bypass this verification. [Learn More] [Login]
File
  • Please read the Rules and FAQ before posting.
  • You may highlight syntax and preserve whitespace by using [code] tags.

08/21/20New boards added: /vrpg/, /vmg/, /vst/ and /vm/
05/04/17New trial board added: /bant/ - International/Random
10/04/16New board for 4chan Pass users: /vip/ - Very Important Posts
[Hide] [Show All]


[Advertise on 4chan]


File: fizzbuzz.jpg (87 KB, 800x1066)
87 KB JPG
90% of /g/ can't solve this problem without the use of AI.
>>
c'mon son u got this
>>
File: noiseposting_explained.png (164 KB, 1339x1034)
164 KB PNG
>>
a = x % 3; b = x % 5;
return (a && b) ? "" :
((!a && !b) ? "FizzBuzz" :
(a ? "Buzz" : "Fizz"));
>>
>>110431148
I don't know how to code tell me how I did

For bepis (1 - n)
If bepis/3 and bepis/5
Print fizzbuzz
Else if bepis/3
Print fizz
Else if bepis/5
Print buzz
Else
Print bepis
The end
>>
>>110431204
you did good
>>
object FizzBuzz {
def main(args: Array[String]) {
for( x <- 1 to 100) {

val divBy3 : Boolean = x % 3 == 0
val divBy5 : Boolean = x % 5 == 0

if (divBy3 && divBy5) {
println("FizzBuzz")
} else if (divBy3) {
println("Fizz")
} else if (divBy5) {
println("Buzz")
} else {
println(x)
}
}
}
}
>>
>>110431148
I can because I watched that one Tom Scott video
>>
File: file.png (28 KB, 964x447)
28 KB PNG
>>110431148
>>
>>110431225
Are you fucking stupid, it says return an array
Dumb fucking nigger can't even fizzbuzz lmao
>>
Arrays are uniform types
x = 1:n;
fizz = mod(x, 3) == 0;
buzz = mod(x, 5) == 0;
num = ~fizz & ~buzz;
y = strings(size(x));
y(fizz) = y(fizz) + "Fizz";
y(buzz) = y(buzz) + "Buzz";
y(num) = string(x(num));
>>
>>110431148
#!/usr/bin/env python3

def fizzbuzz(n):
return [ ( ('fizz' if not x%3 else '') + ('buzz' if not x%5 else '') or x) for x in range(1, n+1) ]

print(fizzbuzz(15) )
>>
in the tranny lang

pub enum FB { Fizz, Buzz, FizzBuzz, Num(u32) }

pub fn fizzbuzz(n: u32) -> Vec<FB> {
(1..=n).map(|i| match (i % 3, i % 5) {
(0, 0) => FB::FizzBuzz,
(0, _) => FB::Fizz,
(_, 0) => FB::Buzz,
_ => FB::Num(i),
}).collect()
}

>>
>>110431148
Nigger
>>
I apply the learnings of the javascript sir
f=n=>[1,2,"Fizz",4,"Buzz","Fizz",7,8,"Fizz","Buzz",11,"Fizz",13,14,"FizzBuzz",16,17,"Fizz",19,"Buzz","Fizz",22,23,"Fizz","Buzz",26,"Fizz",28,29,"FizzBuzz",31,32,"Fizz",34,"Buzz","Fizz",37,38,"Fizz","Buzz",41,"Fizz",43,44,"FizzBuzz",46,47,"Fizz",49,"Buzz","Fizz",52,53,"Fizz","Buzz",56,"Fizz",58,59,"FizzBuzz",61,62,"Fizz",64,"Buzz","Fizz",67,68,"Fizz","Buzz",71,"Fizz",73,74,"FizzBuzz",76,77,"Fizz",79,"Buzz","Fizz",82,83,"Fizz","Buzz",86,"Fizz",88,89,"FizzBuzz",91,92,"Fizz",94,"Buzz","Fizz",97,98,"Fizz","Buzz",101,"Fizz",103,104,"FizzBuzz",106,107,"Fizz",109,"Buzz","Fizz",112,113,"Fizz","Buzz",116,"Fizz",118,119,"FizzBuzz",121,122,"Fizz",124,"Buzz","Fizz",127,128,"Fizz","Buzz",131,"Fizz",133,134,"FizzBuzz",136,137,"Fizz",139,"Buzz","Fizz",142,143,"Fizz","Buzz",146,"Fizz",148,149,"FizzBuzz",151,152,"Fizz",154,"Buzz","Fizz",157,158,"Fizz","Buzz",161,"Fizz",163,164,"FizzBuzz",166,167,"Fizz",169,"Buzz","Fizz",172,173,"Fizz","Buzz",176,"Fizz",178,179,"FizzBuzz",181,182,"Fizz",184,"Buzz","Fizz",187,188,"Fizz","Buzz",191,"Fizz",193,194,"FizzBuzz",196,197,"Fizz",199,"Buzz","Fizz",202,203,"Fizz","Buzz",206,"Fizz",208,209,"FizzBuzz",211,212,"Fizz",214,"Buzz","Fizz",217,218,"Fizz","Buzz",221,"Fizz",223,224,"FizzBuzz",226,227,"Fizz",229,"Buzz","Fizz",232,233,"Fizz","Buzz",236,"Fizz",238,239,"FizzBuzz",241,242,"Fizz",244,"Buzz","Fizz",247,248,"Fizz","Buzz",251,"Fizz",253,254,"FizzBuzz",256,257,"Fizz",259,"Buzz","Fizz",262,263,"Fizz","Buzz",266,"Fizz",268,269,"FizzBuzz",271,272,"Fizz",274,"Buzz","Fizz",277,278,"Fizz","Buzz",281,"Fizz",283,284,"FizzBuzz",286,287,"Fizz",289,"Buzz","Fizz",292,293,"Fizz","Buzz",296,"Fizz",298,299,"FizzBuzz",301,302,"Fizz",304,"Buzz","Fizz",307,308,"Fizz","Buzz",311,"Fizz",313,314,"FizzBuzz",316,317,"Fizz",319,"Buzz","Fizz",322,323,"Fizz","Buzz",326,"Fizz",328,329,"FizzBuzz",331,332,"Fizz",334,"Buzz","Fizz",337,338,"Fizz","Buzz",341,"Fizz",343,344,"FizzBuzz",346,347,"Fizz",349,"Buzz"].slice(0,n)
>>
++++++++++[>++++++++++<-]>>++++++++++>->>>>>>>>>>>>>>>>-->+++++++[->++
++++++++<]>[->+>+>+>+<<<<]+++>>+++>>>++++++++[-<++++<++++<++++>>>]++++
+[-<++++<++++>>]>>-->++++++[->+++++++++++<]>[->+>+>+>+<<<<]+++++>>+>++
++++>++++++>++++++++[-<++++<++++<++++>>>]++++++[-<+++<+++<+++>>>]>>-->
---+[-<+]-<[+[->+]-<<->>>+>[-]++[-->++]-->+++[---++[--<++]---->>-<+>[+
+++[----<++++]--[>]++[-->++]--<]>++[--+[-<+]->>[-]+++++[---->++++]-->[
->+<]>>[.>]++[-->++]]-->+++]---+[-<+]->>-[+>>>+[-<+]->>>++++++++++<<[-
>+>-[>+>>]>[+[-<+>]>+>>]<<<<<<]>>[-]>>>++++++++++<[->-[>+>>]>[+[-<+>]>
+>>]<<<<<]>[-]>>[>++++++[-<++++++++>]<.<<+>+>[-]]<[<[->-<]++++++[->+++
+++++<]>.[-]]<<++++++[-<++++++++>]<.[-]<<[-<+>]+[-<+]->>]+[-]<<<.>>>+[
-<+]-<<]
>>
>>110431928
>tranny lang
>not haskell
>>
>>110431148
this is literally what llm is good for -- tedious loops and string manipulation. i would happily forget it and just pose the question to llm to implement.
>>
>>110432212
your faggot llm refuses to do this

my $n = shift // 100;

my @nigger = map {
$_ % 15 == 0 ? 'nigger' :
$_ % 3 == 0 ? 'nig' :
$_ % 5 == 0 ? 'ger' :
$_
} 1 .. $n;

print join("\n", @nigger), "\n";

>>110432063
>>
>>110431148
baited everypony award
>>
>>110432263
v0.2 with 200% more llm-resistant keywords
my $kike= shift // 100;

my @niggers = map {
$_ % 15 == 0 ? 'niggerfaggot' :
$_ % 3 == 0 ? 'nigger' :
$_ % 5 == 0 ? 'faggot' :
$_
} 1 .. $kike;

print join("\n", @niggers), "\n";


art imitates life
1 in 3 are browns
1 in 5 are gays
1 in 15 are brown gays
and a semite controls the counting
>>
>>110432335
>"return an array ..."
>anon doesn't return the array
>>
section .data
fizz db "Fizz", 0
buzz db "Buzz", 0
fizzbuzz db "FizzBuzz", 0
num_buffer times 12 db 0
limit dq 100

section .bss
result_array resq 1000
num_strings resb 12000

section .text
global _start

_start:
mov rcx, 1
mov rdi, [limit]
mov r8, result_array
mov r9, num_strings

.loop:
cmp rcx, rdi
jg .done

mov rax, rcx
mov rbx, 15
xor rdx, rdx
div rbx
test rdx, rdx
jz .store_fizzbuzz

mov rax, rcx
mov rbx, 3
xor rdx, rdx
div rbx
test rdx, rdx
jz .store_fizz

mov rax, rcx
mov rbx, 5
xor rdx, rdx
div rbx
test rdx, rdx
jz .store_buzz

; Store number as string
call .store_number
jmp .next

.store_fizzbuzz:
mov [r8], qword fizzbuzz
add r8, 8
jmp .next

.store_fizz:
mov [r8], qword fizz
add r8, 8
jmp .next

.store_buzz:
mov [r8], qword buzz
add r8, 8
jmp .next

.next:
inc rcx
jmp .loop

.done:
mov rax, result_array
mov rdx, [limit]
; Exit program
mov rax, 60
xor rdi, rdi
syscall

.store_number:
mov rax, rcx
mov rbx, 10
mov rdi, r9
add rdi, 11
mov byte [rdi], 0

.convert_loop:
dec rdi
xor rdx, rdx
div rbx
add dl, '0'
mov [rdi], dl
test rax, rax
jnz .convert_loop

mov [r8], rdi
add r8, 8
add r9, 12
ret
>>
Usecase?
>>
Oh, and it's stupid that it says to return an array of integers with string inside. It should return an array allowing strings.
>>
>>110431319
>it says return an array
It says return an array of integers, but "Fizz", "Buzz", and "Fizzbuzz" are strings. So now you're returning an array of mixed datatypes.
At that point you just call the interviewer a faggot, turn 360 degrees and walk away.
>>
>>110432406
strings are just multi-byte integers. so just pick a wide enough integer type and return the string's integer representation.
>>
in python this is just
[(n%3==0)*'Fizz'+(n%5==0)*'Buzz' or n for n in range(1,101)]


or if you NEED it as a function
def fizzbuzz(limit):
return [(n%3==0)*'Fizz'+(n%5==0)*'Buzz' or n for n in range(1,limit+1)]

if you don't want to mix strings and integers (probably a good idea) you can do str(n) instead of just returning a number

>>110431550
too bloated
>>
>>110431148
>>110432356
k
def fizz_buzz(n):
global arx
arx=[None for i in range (n)]
for i in range(1,n+1,1):
if (i%3==0 and i%5==0 & i<5): arx[i-1]="FizzBuzz"
elif (i%3==0): arx[i-1]="Fizz"
elif (i%5==0): arx[i-1]="Buzz"
else: arx[i-1]=i
return arx

>>110432406
the datatype is a list and doesn't have a specific type. python feels alien and i hate it since it isn't oriented around types unlike C like langs.
>>
File: 1773285886531868.png (38 KB, 1280x1280)
38 KB PNG
>>110431148
function fizzBuzz(n) { return Array(n).fill().map((_,i)=>i+1).map(x=>x%15===0?"FizzBuzz":x%5===0?"Buzz":x%3===0?"Fizz":x); }

So did I get the job?
>>
>(i%3==0 and i%5==0 & i<5)
pretend as if this was i%15
>>
>>110432550
>>110432597
>>
>>110432551
>not doing [...].map((x,i)=>i+1%15===0[...]
Well call you back.
>>
>>110431148
>without the use of AI
use case?



[Advertise on 4chan]

Delete Post: [File Only] Style:
[Disable Mobile View / Use Desktop Site]

[Enable Mobile View / Use Mobile Site]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.