« first day (1641 days earlier)      last day (3305 days later) » 

6:00 PM
thoughts?
 
@SterlingArcher "the animal in me"? Dude, phrasing.
 
IT WAS THE FOURTH OF JALUOU DROP IT
 
@Catgocat every developer should be doing reviews
 
i'm too lazzy
 
it's not a special skill, you just read things you may not know and comment on them
we require at least 3 devs to +1 a review before it gets merged into our production branches here
then a manager approves the merge request
 
> When confronted with JavaScript, programmers have a choice: You can go Jedi, or you can go JarJar. Overwhelmingly, the most popular choice is to go JarJar.

"Meesa web ninja!"
LMAO
 
omg hahahaha
 
0
Q: Is a NxN Sudoku valid?

CatgocatGiven a multi-dimensional array representing a board in Sudoku, the function should be able to return whether the sudoku is valid or not. Examples: var goodSudoku = new Sudoku([ [7,8,4, 1,5,9, 3,2,6], [5,3,9, 6,7,2, 8,4,1], [6,1,2, 4,3,8, 7,5,9], [9,2,8, 7,1,5, 4,6,3], [3,5,7, 8,4,6,...

Oh man, now that I look at the code it looks ugly as hell.
 
NxN can't be a sudoku unless N is a perfect square
 
6:17 PM
No, NxN == perfect square
there are 2x2 sudokus :p
 
[[1,2],[2,1]]
 
not a sudoku
the blocks are missing
 
@Catgocat Something counterintuitive about code review is that you write better code when you expect others to see it
 
ok then whatever it was a challenge given to me
 
6:18 PM
4x4 sudokus are fine, because they have 4 2x2 blocks
 
@SomeKittens True, but I felt lazzy to reimplement the code. I might just put my new version of it?
 
4x4 is the smallest possible sudoku
 
1x1 maybe
 
4x4, 9x9, 25x25
etc
 
precisely
 
6:19 PM
oh, I missed 16x16
 
anything else has to break the rules of sudoku
 
It's a series, 2^2, 3^2, 4^2, ...
 
if you have a puzzle where rows and columns are unique, that's fine, but different
 
function validSudoku(data) {
	var valid = true,
		temp = [],
		data,
		side,
		slot;


	// Check wrong size
	if (data[0].length !== data.length) valid = false;

	// slot*slot
	slot = Math.sqrt(data.length);

	// Verifiy horizontal
	data.forEach(function(arr) {
		for (var i = 1; i <= arr.length; i++)
			if (arr.indexOf(i) < 0) valid = false;
	});

	// Verifiy vertical lines
	data.forEach(function(arr, i) {
		data.forEach(function(val) {
			temp.push(val[i]);
		});

		for (var i = 1; i <= arr.length; i++)
 
I think I've actually done 16x16 sudokus before
 
6:20 PM
I wrote a new implementation with ES5 functions
 
@Catgocat simple question: does [[1,2,3,4,5,6,7,8,9],[3,2,1,6,5,4,9,8,7],...] get caught as invalid?
 
!!tell Catgocat mdn Array.map
 
if (Math.sqrt(data.length) % 1 !== 0) return false;
 
6:22 PM
if( data.length * data.length % 1 !== data.length * data.length )
sqrt is expensive
you don't need it
 
Why use array.map ?
 
err.
ignore me
 
I'm not inserting any values ..
 
god I'm stupid
 
@KendallFrey It's only longer, if the ratio of revealed/not revealed is maintained, it's not harder.
 
6:23 PM
data.forEach(function(val) {
			temp.push(val[i]);
		});
 
(i.e no extra complexity)
	data.forEach(function(arr, i) {
		data.forEach(function(val) {
			temp.push(val[i]);
		});
 
so Zirak?
Oo
 
@Zirak ^ :D
 
You sure you're not inserting any values?
Also, temp is a terrible name
 
In the temp just..
 
6:24 PM
Would a 16x16 sudoku require 31 clues?
 
@KendallFrey No idea about the minimum
 
!!> console.log( (6*6) % 1, Math.sqrt(36) % 1, 25%1, Math.sqrt(25)%1)
 
@Zirak yea, tmp gets the point across without that stupid extra character
 
@Shmiddty "undefined" Logged: 0,0.4494897427831779
 
How would I map a temporary array that has no length? Doing array.apply... its too expensive that way is alright no?
 
6:24 PM
We only have empirical proof for our current minimum with 9x9, we don't even know why it's that way :D
 
map transforms one array into another
 
@Catgocat Data has length
data.map()
 
@Catgocat Good thing you're not trying to turn temp from one thing to another, then
 
!!tell Catgocat mdn Array.map
 
6:25 PM
I know array.map
stop
 
HAMMERTIME!
 
MDN
 
if you wanna be extra cautious, you slice the map
then no one can argue
 
@Shmiddty "undefined" Logged: 0,0,0,0
 
Whoever proposed the stop listener is a genius
 
6:25 PM
@rlemon Stop slicing my maps
 
duuurrr
 
var newArr = arr.slice().map(fn).slice()
 
@Zirak Can you tell me in a more detailed way what you were suggesting?
Without virtually screaming at me.
 
renameMeFromTemp = data.map(function () { ... });
 
@KendallFrey you should hang out in here: chat.stackexchange.com/rooms/9682/the-pod-bay
for no other reason than because
 
6:29 PM
why
 
@rlemon I totally went off on a wild goose chase trying to figure out what you were talking about. haha
 
@Shmiddty I saw sqrt being used in a comparison and my brain shut off
 
I don't even know why I'm using temp o.O
wait
 
Yeah, the first time I wrote it, I wasn't happy about the second sqrt call, then I realized if the root is a whole number, N%1 === 0
Anything else is a fraction
 
yup that was not needed just removed
 
6:31 PM
@Zirak you should add "collaborate and listen" as a 5% hit chance
 
So the stop listener has been updated?
Funny story, tangentially related to vanilla ice: My first ever date was to the 3rd Ninja Turtles movie
I was in 1st grade
 
Did you hold hands?
 
I totally went for the hand over shoulder move
then she called her brothers
they sat between us for the rest of the movie
 
did you yawn
 
aaawww
 
6:33 PM
I don't remember, I was like 5
 
Cockblocked at 5. Impressive.
 
my first date (grade 6) admitted to only going on the date because she likes chinese food and knew I was going to take her to dinner first.
 
I spent the rest of the pocketful of change at the arcade
but when I say arcade, I mean the SF2 machine at the convenience store
 
  // Verifiy vertical lines
    data.forEach(function(arr, i) {

        temp = data.map(function(val) { return val[i] });

        for (var i = 1; i <= arr.length; i++)
            if (tmp.indexOf(i) < 0) valid = false;

    });
@Zirak
 
Better. Now use arr.some
 
6:34 PM
@rlemon That's cruel
 
if I could own an arcade machine today, Bubble Bobble it would be
<3 that game
 
I liked the competitive modes in those bubble games
 
how? ;p
 
where your actions would hinder the opponent
 
and where
 
6:35 PM
Need I point you to mdn?
 
!!mdn array.map
 
stawp
!!
 
:D
 
@Catgocat That didn't make much sense. Maybe you meant: d, π
 
come on now
 
6:35 PM
No, I won't tell you
 
ok
 
@Catgocat just download the google to your internal memory banks, easy.
 
> I know kung-fu
 
4 upvotes on my codereview question
nice
 
because you followed their rules and posted a question that isn't terrible :P most other smaller sites are really cool like that
 
6:37 PM
@Catgocat you're talkative today. What's going on in your world?
 
you can net a few hundred rep in a few days
 
kool ;D
@Shmiddty Ecstasy
 
kids these days
 
SO makes it harder to get rep. You either get none or 100+ in a day.
@Catgocat don't do E, it's shit
 
with their mollies and their bopits
 
6:38 PM
I don't understand why anyone would willingly use a cut version of a drug they can get just as easily
 
@ssube What's the pure form?
 
@Shmiddty molly
e is just mdma with a bunch of shit in it, like painkillers and rat poison
 
@SterlingArcher me after 3 weeks of codecademy
 
and a variety of other amphetamines
that's why E puts holes in your brain (molly still isn't good for you, but it's not nearly as bad)
 
6:40 PM
valid = arr.every(function(val, i) { return tmp.indexOf(i + 1) < 0; });
@Zirak ?
 
Nice!
 
Ok I went from 30 to 25 lines
 
I'd heard the MDMA supply was dwindling. Or was that some other psychotropic?
 
I can't really to that because if valid is false, the loop will repeat and then if its true..
 
@SterlingArcher meesa neo
 
6:42 PM
I can do valid = valid && .. ?
@Zirak
 
@Shmiddty I legitimately have no idea
 
@Catgocat Can you?
 
@KendallFrey bahaha
 
i am woundering, why does this not work? el.css({name:val }); name and val are dynamicaly given, i am 100% the got the corect values, just checked them also el si a valid selector, why does this not work? i am very confused
 
Or I would just break if valid is false, but the extra line :c
 
6:43 PM
none of my questionable friends have been complaining loudly about anything
 
Me neither. I think I'd heard about it on some documentary on Netflix
 
@ZetCoby how are you building the object?
exactly like that?
 
ops forgot it isnt forloop
 
var obj = {};
obj[name] = val;
el.css(obj);
 
meh.
 
6:43 PM
yeah valid = valid && will do fine
 
If you listen to VICE for too long, you'll think the supply of conceited british 20-somethings willing to risk their lives to get the next big story is dwindling. Sadly, it's not.
 
@rlemon hmm good idea i will try it
 
Serious question: When there is an opportunity to exit early when iterating over a collection, is it always better to do so? E.g. a search algo.
 
If you don't need to continue, then probably yes
 
Usually, if it's clean and obvious.
Search/findFirst is a great example of yes.
 
6:45 PM
Is there a way to force an early exit in array methods?
 
@ZetCoby your way fails because if var name = "width" {name: '100'} <- the object doesn't evaluate 'name', it literally assigns '100' to the property 'name' on the passed object.
 
@Zirak Thanks for the tips though :) Do you think I should improve the function on anything else?
 
@Shmiddty No, only in some, every and find
 
@Shmiddty force, no. Some will do it on their own, most have to hit every element.
 
@rlemon oh by the way they are normal vars
 
6:45 PM
doesn't matter
 
oh
 
you can't use a variable for an object properties key name like that
 
@Zirak That makes sense. As soon as you return false in an every, there's no point in continuing
 
i see
thank you
 
but, "bracket notation" allows you to do that
you just have to define the object outside of the expression (is that the correct term?)
foo(/* inside here is an expression right? */)
^ anyone ??
 
6:47 PM
and in a some, as soon as you return true, it can stop iterating.
Cool. I need to start using Array.find more
 
are there any array methods that can exit early and don't search or return a boolean?
 
now my code broke and have no idea what did
 
@Catgocat The first place to look is always at what has changed since it was last working
 
@Shmiddty @Catgocat git diff
 
6:49 PM
@ssube Is there a way to get just a list of files that have changed?
 
@Shmiddty git status
 
between two commit hashes?
 
although for git to figure out files that have been renamed, you have to stage them.
 
@rlemon second image looks like fonzi decided to program a website lol
 
@Catgocat validSudoku is an adjective+noun, not a verb+something. temp is a bad name. You can probably splat the first two forEachs into one, I don't see you using temp until the loop near the end, slot is oddly some counter you go up to (assigned under a very non-descriptive comment; slot = slot * slot? but the operands are data.length?)
 
6:50 PM
git diff path parent..second, iirc
 
why is temp bad name? Sometimes I just dont know what to call them stuff, besides alphabet letters ;p
 
@Catgocat call it what it is or what it represents
If it's storing a letter, you can call it letter
You want to be clear what the intention of the variable is
 
Oh yeah, you're also redeclaring data
 
ok making the changes
 
You may consider refactoring some of the code into reusable methods if variable names become tricky
!!afk lunch
 
6:53 PM
I feel bad somebody is out there reviewing the code that I posted 10 minutes ago.
I'll update the post.
A dude answered
 
coverage starts in 4 minutes. launch in an hour nasa.gov/multimedia/nasatv
 
thanks
 
@rlemon what's that?
 
a link
 
spacex isn't doing the streaming?
what's the weather look like today?
 
6:58 PM
@SterlingArcher theirs starts at 3:55 I guess
 
hey guys! :d
 

« first day (1641 days earlier)      last day (3305 days later) »